Text File
-
2012年5月3日 22:02
Dear Sirs,
Need help to collect data from text file and export it excel, i dont know if this needs a program, script or a macro.
it should work and collect the data from unlimited number of text files ( Not Only one ).
The red marked text in the is the data needed in
The data imported to excel file should look like this
No. ID No. TYP CPU Speed Ram HDD Date ServiceTag TEXT FILE 1 D12631 D630 Intel(R) Core(TM)2 Duo CPU T7250@ 2.00GHz 2000 Mhz 2048 MiB 74.5 GiB Tue Jan 24 01:48:24 2012 9WQLF3J 1327427728.txt Any help will be highly appreciated and what is the best solution to do this is it script, macro or a program.
Be thankfull if someone could help with fix to get around this
Best regards
Younan
Here is an example of the text file
Ontrack Eraser Report
------------------------------------------------------------
Time of erasure Wed May 02 04:38:41 2012
Erasure session time 00:55:20
Software Version 3.11.02
Overwrites 1
Verify Full
Pattern KrollOntrack Algorithm
Report Security Hash 340d2001e1dee0a8ec518f0e7736e35b
Customer Defined Fields:
PC_ID BD14879
Modell M4300
Media
------------
Disk #1
Model TOSHIBAMK8051GSY
Serial Number 38BBT09XT
Capacity 74.5 GiB
Block Size 512
Type
Erasure Status Success
Smart Status Not available
DMA Not available
Unlock Success
Lock type No locking
Partitions before erasure session
---------------------------------
Type N/A
Size 0 bytes
Hardware Profile
----------------
Motherboard:
Model 0UY141
Manufacturer Dell Inc.
Version 0
Serial .2QBYR3J.CN4864384P1783.
BIOS:
Vendor Dell Inc.
Version A15 (01/20/2010)
System serial 2QBYR3J
USB Ports 10
RAM:
Slot DIMM_B
Size 1024 MiB
Slot DIMM_A
Size 1024 MiB
Slot System board or motherboard
Size 2048 MiB
CPU:
Slot Microprocessor
Product Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz
Vendor Intel Corp.
Capacity 2400 Mhz
Bit 64
Size 2400 Mhz
CPU cache:
Description L2 cache
Size 3072 KiB
Description L1 cache
Size 32 KiB
Devices:
Vendor Intel Corporation
Product 82801HBM/HEM (ICH8M/ICH8M-E) SATA IDE Controller
Description IDE interface
Serial 0
Vendor Intel Corporation
Product 82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller
Description IDE interface
Serial 0
Vendor Broadcom Corporation
Product NetXtreme BCM5755M Gigabit Ethernet PCI Express
Description Ethernet interface
Serial 00:1d:09:db:b1:8c
Vendor Intel Corporation
Product 82801H (ICH8 Family) USB UHCI Controller #3
Description USB Controller
Serial 0
Vendor Intel Corporation
Product 82801H (ICH8 Family) USB UHCI Controller #2
Description USB Controller
Serial 0
Vendor Intel Corporation
Product 82801H (ICH8 Family) USB UHCI Controller #5
Description USB Controller
Serial 0
Vendor Intel Corporation
Product 82801H (ICH8 Family) USB UHCI Controller #4
Description USB Controller
Serial 0
Vendor Intel Corporation
Product 82801H (ICH8 Family) USB UHCI Controller #1
Description USB Controller
Serial 0
Vendor nVidia Corporation
Product G86M [Quadro FX 360M]
Description VGA compatible controller
Serial
Vendor Intel Corporation
Product 82801H (ICH8 Family) USB2 EHCI Controller #1
Description USB Controller
Serial 0
Vendor Intel Corporation
Product 82801H (ICH8 Family) USB2 EHCI Controller #2
Description USB Controller
Serial 0
すべての返信
-
2012年5月3日 22:19
Looks like a nice little project that you could do easily with some VB Script. Unfortunately for you this forum is not a free script disposal service. Here are your options:
- Learn how to script, then come here either with your conceptual questions or when you have a problem with some of the finer points.
- Pay someone to do the job for you.
If you wanted to do the job with a minimum of effort then you could use the File System Object to read your log file, process it, then write the output as a comma or tab delimited text file. Excel would read it as it is if you give it an .xls extension. If you want the report properly formatted then you need to learn how VB Script interfaces with Excel.
- 編集済み OberwaldMicrosoft Community Contributor 2012年5月3日 22:19
- 編集済み OberwaldMicrosoft Community Contributor 2012年5月3日 22:23
- 編集済み OberwaldMicrosoft Community Contributor 2012年5月3日 22:23
- 編集済み OberwaldMicrosoft Community Contributor 2012年5月3日 22:23
-
2012年5月8日 1:59モデレータ
A VBScript program can read the file one line at a time, and check for strings to identify values. As suggested, the easiest approach would be to output in comma delimited format. The script would be run at a command prompt using the cscript host program, so the output can be redirected to a csv file, which can be easily read into Excel. To demonstrate the idea, the snippet below reads the file and searches for two of the values you describe. Note the search strings, and how the lines where the strings are found are parsed to get the values, taking into the account the length of the search strings (which need to be trimmed off):
Option Explicit
Dim strFile, objFSO, objFile, strLine
Dim intDate, strDate, intHDD, strHDD
Const ForReading = 1
' Specify file.
strFile = "c:\scripts\MyFile.txt"
' Open the file for reading.
Set objFSO = CreateObject("Scriptin.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFile, ForReading)
' Read the file.
Do Until objFile.AtEndOfStream
strLine = Trim(objFile.ReadLine)
' Skip blank lines.
If (strLine <> "") Then
' Search for string "Time of erasure).
intDate = InStr(strLine, "Time of erasure")
If (intDate > 0) Then
' String found, parse for "Date".
strDate = Trim(Mid(strLine, intDate + 16))
End If
' Search for string "Capacity".
intHDD = InStr(strLine, "Capacity")
If (intHDD > 0) Then
' String found, parse for "HDD".
strHDD = Trim(Mid(strLine, intHDD + 9))
End If
End If
Loop
' Clean up.
objFile.Close
' Output header line.
Wscript.Echo "Date,HDD"
' Output results comma delimited.
Wscript.Echo strDate & "," & strHDD
-----
Having gotten this far, however, some problems are apparent. First, your example file results in a two line csv file, the header line and a line for one computer. If the file has information on more than one computer, I don't know how the script will be able to tell that. Second, one of the search strings I selected was "Capacity", but I now see that this shows up twice, for two different values. This problem can be overcome if we can be assured that the values follow in a certain order, but now the script needs to keep track of the order, which involves more code.
I did not go farther in my example because I cannot tell in some cases which column in your result file corresponds to which line in red in the text file. I could guess, but only you can tell for sure. In fact, the number of fields does not match the number of red lines. I think the details need to be left up to you. Perhaps my example will get you started.
Richard Mueller - MVP Directory Services
- 回答の候補に設定 Salvador Manaois IIIModerator 2012年5月8日 2:16
-
2012年5月8日 4:39
Capacity appears one time too many.
!. Does file contain information about only one PC?
2. How do you expect to deal with PCs with more than one processor
3. HOw fo yu expect to del with 'Size' which shows up repeatedly?I deal with lexical challenges like this all of the time. We start by writing scripts to analyze as many files as we can get. Sometimes we process thousands of files to verify the file structures. This is time consuming and tedious. It can take a number of hours to validate any set of rules. It also requires someone who understand how to extract this kind of information.
I recommend that you seek a consultant with experience in this kind of file processing. The exact structure of the file cannot be guaranteed from one example of a file.
The second possibility is to learn how to write a script as has been suggested above although i do not think you could learn scripting quickly enough to fullfill you requirements in a reasonably timeframe
The third approach is to purchase one of the many text-to-data proceesing programs available.
¯\_(ツ)_/¯
-
2012年5月13日 16:02モデレータ
Please read this post YounanYY to understand how this forum works. There are also some helpful links within the post comments.
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/a0def745-4831-4de0-a040-63b63e7be7ae
You can also get started here:
http://blogs.technet.com/search/searchresults.aspx?q=search%20text§ions=7618
Best of luck!
Please click "Vote as Helpful" if this post was helpful to you. Thanks!
- 回答としてマーク Cruz_DanielModerator 2012年5月13日 16:02

