convert a text file data to dataframe in python without pandas

Solutions on MaxInterview for convert a text file data to dataframe in python without pandas by the best coders in the world

showing results for - "convert a text file data to dataframe in python without pandas"
Valentina
27 Mar 2018
1import csv
2
3with open('log.txt', 'r') as in_file:
4    stripped = (line.strip() for line in in_file)
5    lines = (line.split(",") for line in stripped if line)
6    with open('log.csv', 'w') as out_file:
7        writer = csv.writer(out_file)
8        writer.writerow(('title', 'intro'))
9        writer.writerows(lines)