[Tutor] Wanted: module to parse out a CSV line
Terry Carroll
carroll@tjc.com
Wed Dec 11 11:40:02 2002
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)