Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

parse with skip

 [1/6] from: moeller_thorsten::gmx::de at: 21-Aug-2000 13:47


Hi List, I have a file containing the following kind of lines: 9;"1081230012";9999999;1000103;0;84.00;0;9999999;0.84;1;"6";0;991030;0;73.92 ;0.84;9;"L";991030;0;108;123;0;" " With this line i like to get rid of the leading "1" ( should be yymmdd 00/01/03 )in the 4th field. For this i like to use the following code: val: 1000000 parse line [skip ";" 2 thru ";" copy text to ";" (if greater? to-integer text val [remove/part text 1])] For most lines in the file this works fine, but if the number before the first semikolon changes to over 9 ( e.g. 21 ) this won't work anymore. Does anyone know why? I tried a few other things but they took too long, because the file is about 270.000 lines big. Thorsten

 [2/6] from: petr:krenzelok:trz:cz at: 21-Aug-2000 13:51


[moeller_thorsten--gmx--de] wrote:
> Hi List, > I have a file containing the following kind of lines:
<<quoted lines omitted: 8>>
> first semikolon changes to over 9 ( e.g. 21 ) this won't work anymore. > Does anyone know why?
somenum: charset "0123456789" parse line [skip somenum ";" .... Cheers, -pekr-

 [3/6] from: moeller_thorsten:gmx at: 21-Aug-2000 15:10


Hi Pekr, thanks for your tip but..... ......that really doesn't work. With your solution "text has no value". What i tried, is to hop over the semikolons for n times and read the contens until the next semikolon. As there are more than one field to be modified as well field 13 and 19 )the solution to skip over the semikolon may be the best. If i understand the guide correctly, Rebol has to ignore everything before the semikolon, but in this case it doesn't. No idea! Thorsten -----Ursprungliche Nachricht----- Von: [Petr--Krenzelok--trz--cz] [mailto:[Petr--Krenzelok--trz--cz]] Gesendet: Montag, 21. August 2000 13:51 An: [list--rebol--com] Betreff: [REBOL] parse with skip Re: [moeller_thorsten--gmx--de] wrote:
> Hi List, > > I have a file containing the following kind of lines: >
9;"1081230012";9999999;1000103;0;84.00;0;9999999;0.84;1;"6";0;991030;0;73.92
> ;0.84;9;"L";991030;0;108;123;0;" " > With this line i like to get rid of the leading "1" ( should be yymmdd
<<quoted lines omitted: 5>>
> first semikolon changes to over 9 ( e.g. 21 ) this won't work anymore. > Does anyone know why?
somenum: charset "0123456789" parse line [skip somenum ";" .... Cheers, -pekr-

 [4/6] from: petr:krenzelok:trz:cz at: 21-Aug-2000 14:06


[Petr--Krenzelok--trz--cz] wrote:
> [moeller_thorsten--gmx--de] wrote: > > Hi List,
<<quoted lines omitted: 19>>
> somenum: charset "0123456789" > parse line [skip somenum ";" ....
nah, what an nonsense, sorry ... should be: num: charset "0123456789" parse line [some num ";" etc ....] ... and even now ... better don't trust my code :-) -pekr-

 [5/6] from: agem:crosswinds at: 21-Aug-2000 16:50


how about (if no ";" inside data!) ? a: {9;"1081230012";9999999;1000103;0;84.00;0;9999999;0.84;1;"6";0;991030;0;73.92;0.84;9;"L";991030;0; 108;123;0;" "} b: parse a ";" { == ["9" "1081230012" "9999999" "1000103" "0" "84.00" "0" "9999999" "0.84" "1" "6" "0" "991030" "0" "73.92" "0.84" "9" "L" "991030" "0" "108" "123" "0" " "] ; block! } Volker

 [6/6] from: brian:hawley:bigfoot at: 21-Aug-2000 13:04


Volker wrote:
>how about (if no ";" inside data!) ? >a:
<<quoted lines omitted: 6>>
>"0" " "] ; block! >}
Actually, that will work even if there is ; in the data, as long as those data are in "". You should probably use b: parse/all a ";" instead, just in case there are spaces in the data outside of quote marks. Another cool trick you can use if the fields have names is set [a b c] parse/all "1;2;3" ";" Does that help? Brian Hawley

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted