[GRLUG] Some perl help
David Pembrook
david at pembrook.net
Sun Jul 3 11:58:28 EDT 2011
I've taken a look at Text::CSV_XS and that looks like it will do nicely.
This would up being 2 threads... how to manipulate an array and csv
handling and I'm glad I got answers to both.
Thanks everyone for your help on this.
Dave
On 7/2/2011 10:41 PM, scott.tanner at comcast.net wrote:
> (Apologies is this came through twice.)
>
> David,
> I know this doesn't exactly answer your question, but I've used the
> Text::CSV_XS module for a while to parse CSV files and have had with
> good results. As Adam alluded to, CSV can get squirrely pretty fast.
>
> http://search.cpan.org/~hmbrand/Text-CSV_XS-0.82/CSV_XS.pm
> <http://search.cpan.org/%7Ehmbrand/Text-CSV_XS-0.82/CSV_XS.pm>
>
>
> Regards,
> Scott
>
>
>
> David Pembrook <david at pembrook.net> wrote:
> >I'm fluent enough in perl to be dangerous. I have a line from a csv
> >file and I want the "columns" in an array without any quotes. Some
> >columns have them, some don't so I can't count on their presence.
> >The quick and dirty way I came up with used a temp array and a counter
> >and know that has to be a better way to handle this.
> > while (<FILE>) {
> > @temp_values2 = split(",", $_);
>
> String splitting is an evil and wrong way to read a delimited record;
> doing so will fail in a fantastic variety of ways. I'm not a Perl
> developer but I'm certain Perl must provide a standard module for
> reading delimited data sets. In Python this would be the "csv" module -
> which allows you to specify field delimiter, line terminator, and field
> quoting style. Don't forget that text files also have encoding - one
> cannot assume text data is ASCII (especially if a user can get anywhere
> near it using cut-n-paste). If it isn't straight-ASCII your string
> splitting will fail in mysterious cases that on visual inspection look
> fine.
>
> --
> Adam Tauno Williams
>
> --
> This message has been scanned for viruses and
> dangerous content by *MailScanner* <http://www.mailscanner.info/>, and is
> believed to be clean.
>
>
> _______________________________________________
> grlug mailing list
> grlug at grlug.org
> http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shinobu.grlug.org/pipermail/grlug/attachments/20110703/431f65c3/attachment.html>
More information about the grlug
mailing list