Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion How would you replace a field in a CSV file?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
grauenw...@gmail.com  
View profile  
 More options Oct 3 2006, 2:01 am
Newsgroups: fa.haskell
From: Grauenw...@gmail.com
Date: 2 Oct 2006 23:01:11 -0700
Local: Tues, Oct 3 2006 2:01 am
Subject: Re: How would you replace a field in a CSV file?
I noticed that the original python version was flawed. In CSV, commas
can be inside a quoted field. Therefore, a simple split isn't good
enough unless you are dead certain that fields are not quoted.

So for a general solution, you need to...

1. Break only on commas outside of quotes
2. Throw away the outer quotes around each field that has them
3. Turn any pairs of quotes inside a quoted string into a quote
4. On output, quote each field that needs it.
5. While processing, ensure the quotes are balanced and that each row
has the correct number of fields.

Jonathan Allen

"A complete solution in BASIC beats a partial solution in any other
langauge."


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.