in reply to Pre-process csv files before using
perl -e '@array = qw (hello world 1 2 3); @req = qw (2 3 4); $str = pr +int join (",",@array[@req]), $/;' __END__ 1,2,3
In the above code i have an array called array then i have a required columns array called req. @array[@req] returns a list with values from the required columns.
Regarding the removal of "." from the header, at what point do you want to do it? Before you start reading the CSV into DBI or when you write out? Before you use it in DBI would require you to do an inplace edit. Writing out the correct header (without period) should be very easy. A simple regex on the your "variable column" array.
perl -e '@wperiod = qw (hi.1 hi.2 hi.3); print join (",", map {s/\.//g +; $_} @wperiod), $/;' __END__ hi1,hi2,hi3
-SK
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pre-process csv files before using
by DrAxeman (Scribe) on Aug 06, 2005 at 18:40 UTC | |
by sk (Curate) on Aug 06, 2005 at 18:51 UTC | |
by DrAxeman (Scribe) on Aug 06, 2005 at 18:58 UTC | |
by davidrw (Prior) on Aug 06, 2005 at 19:26 UTC | |
by sk (Curate) on Aug 06, 2005 at 20:34 UTC | |
by DrAxeman (Scribe) on Aug 06, 2005 at 21:46 UTC | |
| |
by sk (Curate) on Aug 06, 2005 at 19:20 UTC | |
by DrAxeman (Scribe) on Aug 06, 2005 at 20:03 UTC | |
|