The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
[SOLVED] Importing data from a text file
CarlyWarly
Member Posts: 4 Contributor I
Hi all,
I wonder if someone could give me some advice? I am looking to import data from a text file based on pattern/text matching. For example process a text file similar to the below, looking to extract the field after "Directory of" and the corresponding text before "File(s)" and bytes.
So based on the file text file below, I would have three records:
Any help or hints would be greatly accepted
Carl
Directory of C:\Windows\addins
14/07/2009 06:32 <DIR> .
14/07/2009 06:32 <DIR> ..
10/06/2009 22:20 802 FXSEXT.ecf
1 File(s) 802 bytes
Directory of C:\Windows\assembly
12/05/2012 15:24 <DIR> .
12/05/2012 15:24 <DIR> ..
10/06/2009 21:39 66,728 big5.nlp
10/06/2009 21:39 82,172 bopomofo.nlp
10/06/2009 21:39 116,756 ksc.nlp
04/01/2012 04:34 4,567,040 mscorlib.dll
10/06/2009 21:40 59,342 normidna.nlp
10/06/2009 21:40 45,794 normnfc.nlp
10/06/2009 21:40 39,284 normnfd.nlp
10/06/2009 21:40 66,384 normnfkc.nlp
10/06/2009 21:40 60,294 normnfkd.nlp
10/06/2009 21:40 83,748 prc.nlp
10/06/2009 21:40 83,748 prcp.nlp
10/06/2009 21:40 262,148 sortkey.nlp
10/06/2009 21:40 20,320 sorttbls.nlp
10/06/2009 21:40 28,288 xjis.nlp
14 File(s) 5,582,046 bytes
Directory of C:\Windows\AppPatch\en-US
16/04/2011 03:24 <DIR> .
16/04/2011 03:24 <DIR> ..
20/11/2010 13:02 292,352 AcRes.dll.mui
1 File(s) 292,352 bytes
I wonder if someone could give me some advice? I am looking to import data from a text file based on pattern/text matching. For example process a text file similar to the below, looking to extract the field after "Directory of" and the corresponding text before "File(s)" and bytes.
So based on the file text file below, I would have three records:
Path | Files | Size |
C:\Windows\addins | 1 | 802 |
C:\Windows\assembly | 14 | 5,582,046 |
C:\Windows\AppPatch\en-US | 1 | 292,352 |
Carl
Directory of C:\Windows\addins
14/07/2009 06:32 <DIR> .
14/07/2009 06:32 <DIR> ..
10/06/2009 22:20 802 FXSEXT.ecf
1 File(s) 802 bytes
Directory of C:\Windows\assembly
12/05/2012 15:24 <DIR> .
12/05/2012 15:24 <DIR> ..
10/06/2009 21:39 66,728 big5.nlp
10/06/2009 21:39 82,172 bopomofo.nlp
10/06/2009 21:39 116,756 ksc.nlp
04/01/2012 04:34 4,567,040 mscorlib.dll
10/06/2009 21:40 59,342 normidna.nlp
10/06/2009 21:40 45,794 normnfc.nlp
10/06/2009 21:40 39,284 normnfd.nlp
10/06/2009 21:40 66,384 normnfkc.nlp
10/06/2009 21:40 60,294 normnfkd.nlp
10/06/2009 21:40 83,748 prc.nlp
10/06/2009 21:40 83,748 prcp.nlp
10/06/2009 21:40 262,148 sortkey.nlp
10/06/2009 21:40 20,320 sorttbls.nlp
10/06/2009 21:40 28,288 xjis.nlp
14 File(s) 5,582,046 bytes
Directory of C:\Windows\AppPatch\en-US
16/04/2011 03:24 <DIR> .
16/04/2011 03:24 <DIR> ..
20/11/2010 13:02 292,352 AcRes.dll.mui
1 File(s) 292,352 bytes
0
Answers
Almost there I can get it to process individual files and exact the information but not a single file containing multiple entries
Below is working the code and sample files, any help or hints would be greatly accepted, cheers,
Carl
File1.txt
Directory of C:\Windows\addins
14/07/2009 06:32 <DIR> .
14/07/2009 06:32 <DIR> ..
10/06/2009 22:20 802 FXSEXT.ecf
1 File(s) 802 bytes
File2.txt
Directory of C:\Windows\assembly
12/05/2012 15:24 <DIR> .
12/05/2012 15:24 <DIR> ..
10/06/2009 21:39 66,728 big5.nlp
10/06/2009 21:39 82,172 bopomofo.nlp
10/06/2009 21:39 116,756 ksc.nlp
04/01/2012 04:34 4,567,040 mscorlib.dll
10/06/2009 21:40 59,342 normidna.nlp
10/06/2009 21:40 45,794 normnfc.nlp
10/06/2009 21:40 39,284 normnfd.nlp
10/06/2009 21:40 66,384 normnfkc.nlp
10/06/2009 21:40 60,294 normnfkd.nlp
10/06/2009 21:40 83,748 prc.nlp
10/06/2009 21:40 83,748 prcp.nlp
10/06/2009 21:40 262,148 sortkey.nlp
10/06/2009 21:40 20,320 sorttbls.nlp
10/06/2009 21:40 28,288 xjis.nlp
14 File(s) 5,582,046 bytes
File3.txt
Directory of C:\Windows\AppPatch\en-US
16/04/2011 03:24 <DIR> .
16/04/2011 03:24 <DIR> ..
20/11/2010 13:02 292,352 AcRes.dll.mui
1 File(s) 292,352 bytes
probably the Cut Document operator can give you the final boost to accomplish your task.
Best, Marius
Thank for the hint, I have managed to split up the main file into chunks and for each chunk, I can get three fields I need. However, the output is a IOObjectCollection list containing documents.
Any advise on how to convert/extract the values path, files, size into a nice table?
regards,
Carl
try to move the Extract Information operator into a Process Documents operator of its own, as in the process below.
Best,
Marius
Carl