Good morning, I was working with a CSV file in Excel. I usually use python for reading, but I had to perform a very quick operation (add a few rows), so I decided to do it via Excel.
Once I saved the CSV however my read script on python was not working. I then noticed that extra quotes had been added.
from:
"16/09/20 11:50:00";"26.3";"26.6";"60.6";"60.9";"2357.0";"2438.0"
to:
"16/09/20 11:50:00;""26.3"";""26.6"";""60.6"";""60.9"";""2357.0"";""2438.0"""
Is there any way to restore the csv to its original format?
CodePudding user response:
Your whole line got quoted. You can fix by:
df = pd.read_csv('your_messed_up.csv', header=None)
and then:
df[0].str.split(';', expand=True).to_csv('your_new_good.csv', index=None)
CodePudding user response:
If you want to bring it back to its original format you can use find and replace. For example you can replace "" with just ". Hopefully this helps. Here's how to do it:
- Windows: Ctrl H
- Mac: hold "shift" "command" "H" on your keyboard.