CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Advanced:
smart csv perl library


New User

Mar 3, 2009, 8:18 AM

Post #1 of 2 (1841 views)
smart csv perl library Can't Post

I am a data analyst.
I am reading a csv file. Each column in the csv file has a mapping to data based on the column name. e.g.
if csv file is something like:
key, column_b,column_c,column_d,..

then there is a mapping from column_a to a meaningful name coming from another file:
same for column_b, etc..

I need a CSVReader that can be initialized with the mapping files and then be asked to read the csv file, the translation should happen behind the scenes and it should return me mapped column fields.

e.g. usage.

my $csvReader =  new CSVReader(); 
while($csvReader->hasNext()) {
my @columns = $csvReader->readNext();

Is there a library out there that does this smartly and can also take in configuration file specifying how to map column names. If it has other cool features that would be cool too.



(This post was edited by sardare on Mar 3, 2009, 8:19 AM)


Mar 4, 2009, 8:34 AM

Post #2 of 2 (1826 views)
Re: [sardare] smart csv perl library [In reply to] Can't Post

Hi sardare,

I don't think you're going to find a pre-built module for this.

If I understand you correctly, you are looking for a module that:

1. Is initialized with a mapping of csv columns to more "meaningful" values.
1. Steps through a file using stream-like semantics.
2. Maps the columns of each record read to the "meaningful" value.

Tell me, is the mapping by:

1. Column position (e.g., csv column 0 always returns 'foo', regardless of value);
2. Column value (e.g., csv value 'foo' returns 'bar', regardless of postition); or
3. A combination of the two (value 'foo' returns 'bar' if it appears in colunn 1 but might return 'duck' if it appears in column 2)?




Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives