FasterCSV question: skip headers

Hi ,

I am refactoring a class that's using Fastercsv to read a csv file. How do I skip the first (header) line. Now I'm using a helpvariable skipHEADER
but I want a more elegant solution .

Kind regards,

Thiel

If I understand the question correctly, I would recommend setting :headers => true as a FasterCSV option. This will cause it to read the headers in the first row, but not return them. You can then refer to columns by name, instead of by number.

Hope that helps.

James Edward Gray II

···

On Dec 13, 2009, at 6:24 AM, Thiel Chang wrote:

I am refactoring a class that's using Fastercsv to read a csv file. How do I skip the first (header) line. Now I'm using a helpvariable skipHEADER but I want a more elegant solution .

Hi James,

Thanks for your response. I tried the header option. It worked,.

Kind regards,

Thiel

James Edward Gray II schreef:

···

On Dec 13, 2009, at 6:24 AM, Thiel Chang wrote:

I am refactoring a class that's using Fastercsv to read a csv file. How do I skip the first (header) line. Now I'm using a helpvariable skipHEADER but I want a more elegant solution .
    
If I understand the question correctly, I would recommend setting :headers => true as a FasterCSV option. This will cause it to read the headers in the first row, but not return them. You can then refer to columns by name, instead of by number.

Hope that helps.

James Edward Gray II