cfreak has asked for the wisdom of the Perl Monks concerning the following question:
After a long hiatus into the dark and scary world of PHP, I have returned with a question.
I have a project involving the parsing of a large (30MB) tab separated text file. The code was an existing project that I'm new to, the original author used Text::xSV for the parsing, so I don't really have the option to use something else.
The problem is the fields are not quoted in the text file but some of the data contains quotes. What i need is a way for Text::xSV to simply ignore them. I know I can use filtering to change them to some other character and then change them back once they are separated, but I'm hoping there's a better way.
I can't include the actual line due to non-disclosure agreements but its basically somethng like this
00001 Widget ACTIVE widget maker's inc 15"x15"Here is the code I'm using to parse, bascially the same as the example in the pod
Thanks!my $csv = Text::xSV->new(sep=>"\t" ); $csv->open_file("xxxxx.csv"); $csv->read_header(); # Make the headers case insensitive foreach my $field ($csv->get_fields) { if (lc($field) ne $field) { $csv->alias($field, lc($field)); } } while( $csv->get_row() ) { # save to a db }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Text::xSV quote problem
by tilly (Archbishop) on Oct 03, 2006 at 18:30 UTC | |
by cfreak (Chaplain) on Oct 03, 2006 at 22:15 UTC | |
by derby (Abbot) on Oct 04, 2006 at 12:54 UTC | |
Re: Text::xSV quote problem
by grep (Monsignor) on Oct 03, 2006 at 18:17 UTC | |
by cfreak (Chaplain) on Oct 03, 2006 at 18:22 UTC |