“Artco News” artconews@verizon.net schrieb im Newsbeitrag
news:CTDgb.31522$yU5.13084@nwrdny01.gnilink.net…
I thought I ask the scripting guru about the following.
I have a file containing records of data with the following format(first
column is the label):CODE#1^DESCRIPTION^CODE#2^NOTES
NN-110^an info of NN-001^BRY234^some notes
NN-111^1st line data
2nd line data
3rd line data^BRT345^another notes
NN-112^description of NN-112^BBC23^multiline
notes blah
blah
blah
NN-113^info info^MNO12^some notes hereHow do I parse so I can insert them in the database, e.g. MySQL/Access?
Perhaps there are an advanced scripting language can do this easily.
Ruby:
#!/usr/bin/ruby
def process(rec)
while rec.size > 4
dbRec = rec.slice!( 0…3 )
# db insertion here
p dbRec
end
end
rec =
while ( line = gets )
line.chomp!
rec.concat( line.split(‘^’) )
process rec
end
process rec