Reputation: 19
I have CSV file like below:
So first row contains all the columns without comma separation and second row has the data in the first column with comma separation
COLID TEMP1 TEMP2 TEMP3 .....
1,20.1,40.2,8.5
how to read and bring it in
COLID TEMP1 TEMP2 TEMP3
1 20.1 40.2 8.5
dataframe format .
Upvotes: 0
Views: 45
Reputation: 5918
Here, I have named file to be read as text.csv.
Important thing is 'sep' argument where we are telling pandas to read csv which is separated by spaces(\s+) or comma or a tab(\t).
pd.read_csv('test.csv', engine='python', sep='\s+|,|\t')
Output
COLID TEMP1 TEMP2 TEMP3
0 1 20.1 40.2 8.5
Upvotes: 1