RE: script to extract data from text file and put into excel format
Maybe this script can help you out a little bit....... it fills out an excel
spreadsheet with all the values you have in your text file...
Const ForReading = 1
Set objDict = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\test.txt",ForReading)
Do Until objTextFile.AtEndOfStream
strLine = objTextFile.ReadLine
If Instr(strLine,":") Then
arrSplit = Split(strLine,":")
strField = arrSplit(0)
strValue = arrSplit(1)
If Not objDict.Exists(strField) Then
objDict.Add strField,strValue
Else
objDict.Item(strField) = objDict.Item(strField) & "||" & strValue
End If
End If
Loop
objTextFile.Close
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intColumn = 1
For Each strItem In objDict.Keys
objExcel.Cells(1,intColumn) = strItem
intColumn = intColumn + 1
Next
intColumn = 1
For Each strItem In objDict.Items
arrValues = Split(strItem,"||")
intRow = 1
For Each strValue In arrValues
intRow = intRow + 1
objExcel.Cells(intRow,intColumn) = strValue
Next
intColumn = intColumn + 1
Next
It worked for me, but I don't know if it did the way you want it to....
Good luck!
Re: script to extract data from text file and put into excel format
Why use complex vb scripting and not something simple like intelliget
script. Your script would look like:
userVariables = computerName, logFile, eventCode;
{startCriteria = IsSubstring("Category",Line(0));
computerName = Field(Line(1),2);
logFile = Field(Line(2),2);
eventCode = Field(Line(3),2);
output = Concat(computerName, ",", logFile, "," eventCode);
}
Re: script to extract data from text file and put into excel format
I know a script to extract data form txt file in bat
Code:
@echo off > new.txt
for %%T in (*.txt) do find "MACHINING CYCLE TIME" < %%T >> new.txt
And for data extraction, try using the product intelliget that is available at http://www.mountonetech.com/products.asp.