Reputation: 913
I have a tab seperated csv file like below:
1 2 3 4 5 6 7 8 9 10
a b c d e f g h i j
k l m n o p q r s t
And, I'm reading it to a dataframe with the below code
df = pd.read_csv('C:/Users/IBM_ADMIN/Desktop/Delete/input1.csv',encoding='ANSI', delimiter='\t', header=0)
When I execute the above code I'm getting output like this image -> what_I_got
But, I'm expecting like this -> desired_output
I tried many ways to split the column but it's not working.Could you help me with a solution please?
Upvotes: 1
Views: 2092
Reputation: 862541
You need remove delimiter='\t'
- separator is ,
.
It working because default separator is ,
, also is possible remove header=0
because if not parmeter names
by default header=0
:
df = pd.read_csv('C:/Users/IBM_ADMIN/Desktop/Delete/input1.csv',encoding='ANSI')
Upvotes: 3