New Project - نوشته شده در (1059 Views)
Advanced Member
Carefree
مطلب: 4224
4224
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?
Code:

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

Never mind, solved it.
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Development Team Member
Davio
مطلب: 12217
12217
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.
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
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.
Code:

<!--#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
%>
 
شما باید یک متن وارد کنید