Hi all,
Just to start off, I did go through the archives and looked up parsing. There were some helpfull answers, but I'll admit - I'm still a llittle lost on some of the solutions.
I have a file that looks like this:
00REP4835011210111739HENRYV 011210
01PMT00001HENRYV 323118135 0000001112491400112100000000000001009
01PMT00002HENRYV 323118135 0000019000000000112100000000000001045
990003000000000000011612600000000049340325150
I need to delete the first and last rows. I also need to remove spaces and deliniate the information using commas for the remaining rows.
Any suggestions on how to do this? Thanks in advance.
ADP_MAN
Parse a .txt file
Moderators: JRL, Dorian (MJT support)
For the Seperate command, its says "Separate>list,delimiter,returnvar"
What would the "list" be if I was working off of one file? In other words, if my file name was "Jones.txt" would I type:
Seperate>Jones.txt,,,information
Would this then parse the "Jones.txt" file using commas? Also, how would it know where to parse? Should I put a space " " in the "delimiter" filed instead of a comma? Thanks again.
What would the "list" be if I was working off of one file? In other words, if my file name was "Jones.txt" would I type:
Seperate>Jones.txt,,,information
Would this then parse the "Jones.txt" file using commas? Also, how would it know where to parse? Should I put a space " " in the "delimiter" filed instead of a comma? Thanks again.
OK let's have a look ...
With Autohotkey (another advanced scripting tool) you would use these commands
IfInString - Checks if a variable contains the specified string.
then
StringReplace - Replaces the specified substring with a new string
or
StringSplit - Divides a string into an array of substrings using the specified delimiters
or
Loop, parse - Retrieves substrings (fields) from a string, one by one.
Macro Scheduler offers you the option to use Visual Basic Script (VBS) to use an equivalent funtionality within your scripts. Using its standard commands to parse files can be a challenge and is less flexible. Lets assume ...
a) your file has only 4 lines by default (and only the 2nd and 3rd line are of interest to you)
b) those lines are following a field (length) specification
With Autohotkey (another advanced scripting tool) you would use these commands
IfInString - Checks if a variable contains the specified string.
then
StringReplace - Replaces the specified substring with a new string
or
StringSplit - Divides a string into an array of substrings using the specified delimiters
or
Loop, parse - Retrieves substrings (fields) from a string, one by one.
Macro Scheduler offers you the option to use Visual Basic Script (VBS) to use an equivalent funtionality within your scripts. Using its standard commands to parse files can be a challenge and is less flexible. Lets assume ...
a) your file has only 4 lines by default (and only the 2nd and 3rd line are of interest to you)
b) those lines are following a field (length) specification
01PMT00002HENRYV 323118135 0000019000000000112100000000000001045
Let>ln=1
Label>ParseFile
Add>ln,1
ReadLn>C:\MyInputFile.txt,%ln%,Line
MidString>Line,1,16,1stColumn
MidString>Line,18,9,2ndColumn
MidString>Line,28,37,3rdColumn
MessageModal>%1stColumn%,%2ndColumn%,%3rdColumn%
WriteLn>C:\MyOutputFile.txt,Result,%1stColumn%,%2ndColumn%,%3rdColumn%
If>ln3, ParseFile
Label>Exit
Wait>2
Execute>C:\MyOutputFile.txt