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

[REBOL] Re: Parsing data

From: greggirwin:starband at: 8-Oct-2001 20:15

Hi John, << This looks like it is relying on a fixed length file. Here is the problem, the files being parsed are a row of times that appear in a format like this 08:45 08:53 etc.etc. Tab delimited but there are coded department data that preface the line like this: FMK L-300 6:57 7:06 7:13 7:19 7:28 7:36 L-300 FMK FMK L-300 7:29 7:38 7:45 8:00 8:08 8:12 8:15 8:24 L-300 FMK The length is a unknown variable of tab delimited time values. >> OK, if I understand correctly, each *line* starts with these two items: FMK L-300 ...and ends with these two items: L-300 FMK If that is correct, then what I posted should work just fine. What I posted is hard coded to deal with 2 leading and 2 trailing items that you want to eliminate. E.g.
>> mid: func [s start len][return copy/part at s start len] >> tmp: [1 2 3 4 5 6]
== [1 2 3 4 5 6]
>> mid tmp 3 (length? tmp) - 4
== [3 4]
>> tmp: [1 2 3 4 5 6 7 8 9 10]
== [1 2 3 4 5 6 7 8 9 10]
>> mid tmp 3 (length? tmp) - 4
== [3 4 5 6 7 8] If you have a variable number of leading or trailing items then you will need to do a little more work but, once you find their locations, you can still use the mid function to extract what you want. --Gregg