Didn't get a reply awhile ago on this so I'm going to ask again (seems
everyone got caught in the CSV discussion :)).

scenario:

file with lines of data, tab delimited fields.

datadatadata^tdatadata^tmoredata^n

Now, I can suck this up with parse and write it back but end up with one
huge block of series.
[{datadata ^t^t^tdatamoredata^tfoo^n}(repeat...)]

(converts from TDV to rebol format)

foreach file load indir [
  dat: read/lines rejoin [indir file]

  print rejoin ["Converting " file]
  block: make block! 1000
  heading: parse/all first dat "^n"

  foreach line next dat [append block parse/all line "^n"]

  save rejoin [outdir file] head insert/only head block heading
]

Ideally I would like to be able to dump back out to a file as:
[
[my data stuff^tmore of this record^n]
[repeat more data..]
]

(reads back in what we wrote above to verify its format)

foreach file load indir [
  dat: load rejoin [indir file]

  foreach blk next dat [
    ; perl equiv in a nutshell ->  ($var1, $var2, $var3, $var4, $therest) =
split("\t",$_);

    set [name userid grp online offline created code gen res xp yp rad url
blurb
        street city phone fax mobile hotline email key hist virt imag1 cap1
desc1
        img2 cap2 desc2 img3 cap3 desc3 access flags] parse/all blk "^t"
    print name
  ]
]

Kinda like a block in a block I was thinking.  Better yet (this is my C side
thinking) being able to load and save objects (records). I have noticed in
the core dictionary that: set [d e] [1 2] would be something I probably
wouldn't
mind either but am not quite able to get parse to spit things out right,
tried: set [var1 var2 var3] parse/all data newline

Regards,
Deryk


Reply via email to