parsing - Re-format items inside list read from CSV file in Python -
I have some lines in the CSV file like:
1000001234, account name, 0 , 0, "3,711.32", 0,0, "18,629.64", "22,340.96", COD, "20,000.00", some strings, some string 2
If you see, there are some numbers "" Is enclosed in and there is a thousand separator ",". I want to remove the thousand separator and double coat enclosure. For the Qoute enclosure, I'm thinking of using string.replace (), but how about commas in quotation marks?
What is the best way to do this in Python?
You can simply parse CSV, make necessary changes and then write it again .
(I have not tested this code but this should be something like this)
Import CSV Reader = CSV Reader (open ('IN.csv', 'r')) Author = csv.writer (open ('OUT.csv', 'w') for the line in the reader: # Authors have a list. Author (line)
Comments
Post a Comment