I have a text file with the value formatted as follows, please note there there is no separator between values.
"col1""col2""col3""col4"
"val1""date1""number1""val1"
"val2""date2""number2""val2"
"val3""date3""number3""val3"
"val4""date4""number4""val4"
How do I read this file as csv in pandas ?
>Solution :
Here’s a working solution – not the most elegant, but does the job:
mylist = []
with open("filename.csv", 'r') as infile:
for line in infile.readlines():
mylist.append(line[1:-2].split('""'))
data = pd.Dataframe(mylist)