Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 New Project

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
Carefree Posted - 16 March 2013 : 05:23:29
I am writing some code and want to do some data extraction from text files using FSO. I want to scan a document into memory and save it as .txt using OCR. Then use FSO to read the document and look for specific data patterns (e.g., the word Snitz) which will be extracted and stored in the database. I know how to open a document for reading, just not sure how to grab the data I need to capture. Maybe something like this?


If instr(OpenFileobj.ReadLine,"Snitz")>1 Then
	my_Conn.Execute("INSERT INTO TABLE (FOUND) VALUES ('Snitz')")
End If


Never mind, solved it.
2   L A T E S T    R E P L I E S    (Newest First)
Carefree Posted - 16 March 2013 : 16:23:40
This is the gist of it. I removed the functions concerning what is to be done with the data, etc.; since that doesn't effect the extraction procedure. Since there is a specific pattern to the data I wish to extract, I didn't use a form input field allowing it to be actively defined. Now my only hurdle will be ensuring the best quality scan/OCR conversion to text.


<!--#INCLUDE FILE="config.asp"-->
<!--#INCLUDE FILE="inc_sha256.asp"-->
<!--#INCLUDE FILE="inc_header.asp" -->
<%
If len(trim(Request.Form("FullFilePath"))) > 0 Then
	Dim objFSO, FilePath, FullFilePath
	Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
	FilePath=Server.MapPath(Request.Form("FullFilePath"))
	If objFSO.FileExists(FilePath)Then
		Const fsoForReading = 1
		iomode=1
		Dim objTextStream
		Set objTextStream = objFSO.OpenTextFile(FilePath, fsoForReading)
		Do while not objTextStream.AtEndOfStream
			strStart="":strEnd=""
			strLine=objTextStream.ReadLine
			For i = 1 to len(strLine)
				If mid(strLine,i,3)=".az" Then
					For j=1 to len(strLine)
						If mid(strLine,j,1)="!" Then
							Exit For
						End If
					Next
					intLen=j+1-i
					strData=mid(strLine,i,intLen)
					For j=1 to len(strData)
						If mid(strData,j,1)=" " Then
							strStart=left(strData,j-1)
							strEnd=mid(strData,j+1)
						Exit For
						End if
					Next
				End if
			Next
			If strStart>"" Then
				Response.Write	"<form action=""Data.asp"" method=""post"">" & vbNewLine & _
					"	<input type=""hidden"" name=""ID"" value=""" & intID & """>" & vbNewLine & _
					"	<table align=""center"" width=""75%"" bgColor=""transparent"" border=""0"" style=""border-collapse:collapse;"" cellpadding=""0"" cellspacing=""0"">" & vbNewLine & _
					"		<tr valign=""middle"">" & vbNewLine & _
					"			<td align=""center"" width=""100%"">" & vbNewLine & _
					"				<table align=""center"" width=""100%"" bgColor=""black"" border=""1"" cellpadding=""4"" cellspacing=""1"">" & vbNewLine & _
					"					<tr valign=""middle"">" & vbNewLine & _
					"						<td align=""center"" width=""100%"" colspan=""2"" bgColor=""lightblue"">" & vbNewLine & _
					"							<font face=""courier new"" size=""6"" color=""navy""><b>Data Info</b>" & vbNewLine & _
					"							</font>" & vbNewLine & _
					"						</td>" & vbNewLine & _
					"					</tr>" & vbNewLine & _
					"					<tr valign=""middle"">" & vbNewLine & _
					"						<td align=""center"" width=""50%"" bgColor=""lightgrey"">" & vbNewLine & _
					"							<font face=""courier new"" size=""5"" color=""black""><b>Start</b>" & vbNewLine & _
					"							</font>" & vbNewLine & _
					"						</td>" & vbNewLine & _
					"						<td align=""center"" width=""50%"" bgColor=""lightgrey"">" & vbNewLine & _
					"							<font face=""courier new"" size=""5"" color=""black""><b>End</b>" & vbNewLine & _
					"							</font>" & vbNewLine & _
					"						</td>" & vbNewLine & _
					"					</tr>" & vbNewLine & _
					"					<tr valign=""middle"">" & vbNewLine & _
					"						<td align=""center"" width=""50%"" bgColor=""white"">" & vbNewLine & _
					"							<font face=""courier new"" size=""4"" color=""navy"">" & vbNewLine & _
					"								<input type=""text"" size=""100"" maxwidth=""255"" name=""strStart"" value=""" & strStart & """>" & vbNewLine & _
					"							</font>" & vbNewLine & _
					"						</td>" & vbNewLine & _
					"						<td align=""center"" width=""50%"" bgColor=""white"">" & vbNewLine & _
					"							<font face=""courier new"" size=""4"" color=""navy"">" & vbNewLine & _
					"								<input type=""text"" size=""100"" maxwidth=""255"" name=""strEnd"" value=""" & strEnd & """>" & vbNewLine & _
					"							</font>" & vbNewLine & _
					"						</td>" & vbNewLine & _
					"					</tr>" & vbNewLine & _
					"				</table>" & vbNewLine & _
					"			</td>" & vbNewLine & _
					"		</tr>" & vbNewLine & _
					"		<tr valign=""top"">" & vbNewLine & _
					"			<td align=""center"" width=""100%"" bgColor=""transparent"">" & vbNewLine & _
					"				<input type=""image"" src="""& strImageURL &"submit.png"" height=""40"" width=""80"" value=""Add New"">" & vbNewLine & _
					"			</td>" & vbNewLine & _
					"		</tr>" & vbNewLine & _
					"	</table>" & vbNewLine & _
					"</form>" & vbNewLine
'				Exit Do
			End If
		Loop
		objTextStream.Close
		Set objTextStream=Nothing
	Else
		Response.Write	"File not found!"
		WriteFooter
		Response.End
	End if
	Set objFSO = Nothing	
Else
	'Create Form
	Response.Write	"<form action=""map.asp"" method=""post"">" & vbNewLine & _
		"	<table align=""center"" width=""75%"" bgColor=""transparent"" border=""0"" style=""border-collapse:collapse;"" cellpadding=""0"" cellspacing=""0"">" & vbNewLine & _
		"		<tr valign=""middle"">" & vbNewLine & _
		"			<td align=""center"" width=""100%"">" & vbNewLine & _
		"				<table align=""center"" width=""100%"" bgColor=""black"" border=""1"" cellpadding=""4"" cellspacing=""1"">" & vbNewLine & _
		"					<tr valign=""middle"">" & vbNewLine & _
		"						<td align=""center"" width=""100%"" bgColor=""lightblue"">" & vbNewLine & _
		"							<font face=""courier new"" size=""6"" color=""navy""><b>Source File</b>" & vbNewLine & _
		"							</font>" & vbNewLine & _
		"						</td>" & vbNewLine & _
		"					</tr>" & vbNewLine & _
		"					<tr valign=""middle"">" & vbNewLine & _
		"						<td align=""center"" width=""100%"" bgColor=""white"">" & vbNewLine & _
		"							<font face=""courier new"" size=""4"" color=""navy"">" & vbNewLine & _
		"								<input type=""text"" size=""100"" maxwidth=""255"" name=""FullFilePath"" value="""">" & vbNewLine & _
		"							</font>" & vbNewLine & _
		"						</td>" & vbNewLine & _
		"					</tr>" & vbNewLine & _
		"				</table>" & vbNewLine & _
		"			</td>" & vbNewLine & _
		"		</tr>" & vbNewLine & _
		"		<tr valign=""top"">" & vbNewLine & _
		"			<td align=""center"" width=""100%"" bgColor=""transparent"">" & vbNewLine & _
		"				<input type=""image"" src="""& strImageURL &"submit.png"" height=""40"" width=""80"" value=""Submit"">" & vbNewLine & _
		"			</td>" & vbNewLine & _
		"		</tr>" & vbNewLine & _
		"	</table>" & vbNewLine & _
		"</form>" & vbNewLine
End If
WriteFooter
%>
Davio Posted - 16 March 2013 : 13:29:42
Well Carefree, we are all about sharing and helping out each other here. So feel free to share your solution so we can learn from it.

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000 Version 3.4.07