joec_ has asked for the wisdom of the Perl Monks concerning the following question:
...
3 6 8 09
5 7 9 5
END
$$$$
5 9 0 -7
7 9 3 6
END
$$$$
I have a CSV file which contains data related to each group above. The first row in the CSV is a header row with column names.
My csv looks like
Column 1, Column 2
Data 1, Data 2
Data 3, Data 4
I would like to end up with an output file like:
...
3 6 8 09
5 7 9 5
END
> <Column 1>
Data 1
> <Column 2>
Data 2
$$$$
5 9 0 -7
7 9 3 6
END
> <Column 1>
Data 3
> <Column 2>
Data 4
$$$$
Basically, the csv data has been merged between the END keyword and $$$$. I have tried:
while (<DATAFILE>){ $string = $string.$_; } @individual = split /\$\$\$\$/,$string; foreach $i (@individual){ print "inside outer foreach\n"; foreach $h (@headers){ print "inside header foreach - appending tags\n"; @seperate = $i."> <$h>\n"; } @seperate = $i.'$$$$'; } open (OUT, ">outtest.out"); print OUT @seperate;
What this does is just print '$$$$'.
Any help appreciated.
Thanks - Joe.
@headers came from just reading the first line of the csv
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Appending data to large files
by moritz (Cardinal) on Jan 13, 2009 at 16:30 UTC | |
|
Re: Appending data to large files
by kyle (Abbot) on Jan 13, 2009 at 16:36 UTC | |
by joec_ (Scribe) on Jan 13, 2009 at 17:24 UTC | |
by kyle (Abbot) on Jan 13, 2009 at 17:45 UTC | |
by joec_ (Scribe) on Jan 14, 2009 at 09:37 UTC | |
by kyle (Abbot) on Jan 14, 2009 at 13:33 UTC | |
|
Re: Appending data to large files
by hbm (Hermit) on Jan 13, 2009 at 16:36 UTC |