Separation help
Moderators: JRL, Dorian (MJT support)
Separation help
Hello,
I have this string of text:
-rw-r--r-- 1 1000 1001 1287419 May 14 16:12 A02_05_14_2012_1FIRST_1_K0_HN.pdf
-rw-r--r-- 1 1000 1001 979252 May 14 15:15 A03_05_14_2012_1FIRST_1_K0_HN.pdf
I want to separate to get the file size, but when I separate them, they dont give me the consistent position
Readfile>c:\dirfile.txt,data
separate>data,CRLF,data
separate>data_1, ,size1
I try to capture the file size, but the large file is listed under SIZE1_17 and the smaller file size is listed under SIZE1_18, how can I get them in the same place all the time
thank you
I have this string of text:
-rw-r--r-- 1 1000 1001 1287419 May 14 16:12 A02_05_14_2012_1FIRST_1_K0_HN.pdf
-rw-r--r-- 1 1000 1001 979252 May 14 15:15 A03_05_14_2012_1FIRST_1_K0_HN.pdf
I want to separate to get the file size, but when I separate them, they dont give me the consistent position
Readfile>c:\dirfile.txt,data
separate>data,CRLF,data
separate>data_1, ,size1
I try to capture the file size, but the large file is listed under SIZE1_17 and the smaller file size is listed under SIZE1_18, how can I get them in the same place all the time
thank you
Actually I am getting the list from FTPGetDirList and CRLF works fine, it just individual line giving me problem.
I am trying to get the "979252" and "3777934" since they are not the same length, with space in the front it create some difficulty.
there are spaces between element in the line, not tab
I am trying to get the "979252" and "3777934" since they are not the same length, with space in the front it create some difficulty.
there are spaces between element in the line, not tab
OK I think I see the issue. Varying numbers of spaces. This works with the fake data I created. Does it work with your real data? Basically running through the separated items and renumbering them based on whether or not they contain text.
Code: Select all
LabelToVar>Data,data
Separate>data,crlf,Line
Let>kk=0
Repeat>kk
Add>kk,1
Let>value=Line_%kk%
Separate>value,space,item
Let>ii=0
Let>gg=0
Repeat>ii
Add>ii,1
Let>value=item_%ii%
If>value=
Else
Add>gg,1
Let>Test_%gg%=value
EndIf
Until>ii=item_count
Let>Line_%kk%_size=Test_5
Until>kk={%Line_Count%-1}
**BREAKPOINT**
/*
Data:
-rw-r--r-- 1 1000 1001 1287419 May 14 16:12 A02_05_14_2012_1FIRST_1_K0_HN.pdf
-rw-r--r-- 1 1000 1001 979252 May 14 15:15 A03_05_14_2012_1FIRST_1_K0_HN.pdf
-rw-r--r-- 1 1000 1001 419 May 14 16:12 A02_05_14_2012_1FIRST_1_K0_HN.pdf
-rw-r--r-- 1 1000 1001 9252 May 14 15:15 A03_05_14_2012_1FIRST_1_K0_HN.pdf
-rw-r--r-- 1 1000 1001 19 May 14 16:12 A02_05_14_2012_1FIRST_1_K0_HN.pdf
-rw-r--r-- 1 1000 1001 39252 May 14 15:15 A03_05_14_2012_1FIRST_1_K0_HN.pdf
*/
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
If the problem really is multiple spaces then try:
Code: Select all
Readfile>c:\dirfile.txt,data
Separate>data,crlf,Line
Let>kk=0
Repeat>kk
Add>kk,1
Let>value=Line_%kk%
Separate>value,space,item
Let>ff=%item_count%-9
If>ff>0
Let>qq=0
Repeat>qq
Add>qq,1
StringReplace>value, , ,value
Until>qq=ff
EndIf
Separate>value,space,item
MDL>item_5
Until>kk={%Line_Count%}
There sure is... and its shorter and simpler too!Me_again wrote:There is probably a regex solution too.
Code: Select all
Let>line=-rw-r--r-- 1 1000 1001 1287419 May 14 16:12 A02_05_14_2012_1FIRST_1_K0_HN.pdf
Let>pattern=[^0-9]+(\d+) +(\d+) +(\d+) +(\d+).*
RegEx>pattern,line,0,matches,num,1,$4,file_size
MDL>file_size
Let>line=-rw-r--r-- 1 1000 1001 979252 May 14 15:15 A03_05_14_2012_1FIRST_1_K0_HN.pdf
Let>pattern=[^0-9]+(\d+) +(\d+) +(\d+) +(\d+).*
RegEx>pattern,line,0,matches,num,1,$4,file_size
MDL>file_size
- start with one or more non-digits
- followed by one or more contiguous digits
- followed by one or more contiguous spaces
- followed by one or more contiguous digits
- followed by one or more contiguous spaces
- followed by one or more contiguous digits
- followed by one or more contiguous spaces
- followed by one or more contiguous digits - which is the file size
Enjoy!
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
You could also use a MidStr command based on the longer positions and LTrim the result
Code: Select all
Let>string1=-rw-r--r-- 1 1000 1001 1287419 May 14 16:12 A02_05_14_2012_1FIRST_1_K0_HN.pdf
Let>string2=-rw-r--r-- 1 1000 1001 979252 May 14 15:15 A03_05_14_2012_1FIRST_1_K0_HN.pdf
Let>string3=-rw-r--r-- 1 1000 1001 419 May 14 16:12 A02_05_14_2012_1FIRST_1_K0_HN.pdf
Let>string4=-rw-r--r-- 1 1000 1001 19 May 14 16:12 A02_05_14_2012_1FIRST_1_K0_HN.pdf
MidStr>%string1%,24,7,len1
MidStr>%string2%,24,7,len2
MidStr>%string3%,24,7,len3
MidStr>%string4%,24,7,len4
LTrim>%len1%,len1
LTrim>%len2%,len2
LTrim>%len3%,len3
LTrim>%len4%,len4
MessageModal>1=%len1%%CRLF%2=%len2%%CRLF%3=%len3%%CRLF%4=%len4%
Last edited by Bob Hansen on Fri May 18, 2012 2:05 am, edited 2 times in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Well, this is shorter and simplerjpuziano wrote:There sure is... and its shorter and simpler too!Me_again wrote:There is probably a regex solution too.

Code: Select all
Let>pattern=[ ]{1,}
Readfile>c:\dirfile.txt,data
Separate>data,crlf,Line
Let>kk=0
Repeat>kk
Add>kk,1
Let>value=Line_%kk%
RegEx>pattern,value,0,matches,num,1, ,value
Separate>value, ,item
MDL>item_5
Until>kk={%Line_Count%}
Clever concept Me_again, thanks for sharing.Me_again wrote:Well, this is shorter and simpler![]()
Code: Select all
Let>pattern=[ ]{1,} Readfile>c:\dirfile.txt,data Separate>data,crlf,Line Let>kk=0 Repeat>kk Add>kk,1 Let>value=Line_%kk% RegEx>pattern,value,0,matches,num,1, ,value Separate>value, ,item MDL>item_5 Until>kk={%Line_Count%}
However by using the regex I posted, we can reduce it from 11 down to 9 lines... see below:
Code: Select all
Let>pattern=[^0-9]+(\d+) +(\d+) +(\d+) +(\d+).*
Readfile>c:\dirfile.txt,data
Separate>data,crlf,Line
Let>kk=0
Repeat>kk
Add>kk,1
RegEx>pattern,Line_%kk%,0,matches,num,1,$4,file_size
MDL>file_size
Until>kk={%Line_Count%}
Last edited by jpuziano on Fri May 18, 2012 4:42 pm, edited 1 time in total.
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
