[Tutor] Wanted: module to parse out a CSV line

andy surany mongo57a@comcast.net
Wed Dec 11 11:57:38 2002


Thanks Terry. I think I'll re-write my code to use ASV.....

-----Original Message-----
From: Terry Carroll <carroll@tjc.com>
To: andy surany <mongo57a@comcast.net>
Cc: tutor@python.org <tutor@python.org>
Date: Wednesday, December 11, 2002 11:40 AM
Subject: Re: [Tutor] Wanted: module to parse out a CSV line


>On Wed, 11 Dec 2002, andy surany wrote:
>
>> Is there an advantage to using something like asv or csv over opening
>> the file, reading each line, and using string.split (line_contents,
>> ',')?
>
>The biggest reasons are that you want to handle a fiels that may or may
>not be surrounded by quotes, and that may have embedded commas.
>
>For example, consider the string:
>
>  "Programming Python","Lutz, Mark",1-56592-197-6
>
>A good CSV module will parse this into three elements:
>  Programming Python
>  Lutz, Mark
>  1-56592-197-6
>
>A plain old comma-split will parse it into four elements, and leave the
>quote marks:
>
>  "Programming Python"
>  "Lutz
>   Mark"
>  1-56592-197-6
>
>
>--
>Terry Carroll        |
>Santa Clara, CA      |   "The parties are advised to chill."
>carroll@tjc.com      |       - Mattel, Inc. v. MCA Records, Inc.,
>Modell delendus est  |         no. 98-56577 (9th Cir. July 24, 2002)
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor