I have been struggling with code for the following and would appreciate any advice.
Read thru a specific file folder and read the first line of each file within the folder. All are text files.
While doing this I would like to parse the 1st line and write specific fields from the line to another single text file. The First line is delimited by pipe.
OuterLoop>ReadFile
InnerLoop>ReadLine, write results
Thanks, Ed
Inner Outer Loops
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
If I've followed you correctly there's actually only one loop here. Something like:
Code: Select all
//get list of files in folder
GetFileList>c:\folder\*.*,file_list
Separate>file_list,;,files
//loop through list of files
Let>k=0
Repeat>k
Let>k=k+1
Let>this_file=files_%k%
//read first line of file
ReadLn>this_file,1,line
//split line into fields using pipe as delimiter
Separate>line,|,fields
//write fields 1,3, and 5 to another file
WriteLn>outputfile,res,fields_1
WriteLn>outputfile,res,fields_2
WriteLn>outputfile,res,fields_3
//or, say you want them on the same line:
WriteLn>outputfile,res,%fields_1% %fields_2%, %fields_3%
Until>k=files_count
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?