Reputation: 125
I am attempting to read a CSV via Pandas. The code works fine but the result does not properly separate the data. Below is my code:
df = pd.read_csv('data.csv', encoding='utf-16', sep='\\', error_bad_lines=False)
df.loc[:3]
When I run this the output looks something like this:
Anything I can do to adjust this? All help is appreciated!
Upvotes: 0
Views: 1232
Reputation: 85
Just use \t as sep argument while reading csv file
import pandas as pd
import io
data="""id\tname\temail
1\tJohn\[email protected]
2\tJoe\[email protected]
"""
df = pd.read_csv(io.StringIO(data),sep="\t")
you dont need IO, its just for example.
Upvotes: 1