Answers for "convert a text file data to dataframe in python without pandas"

0

convert a text file data to dataframe in python without pandas

import csv

with open('log.txt', 'r') as in_file:
    stripped = (line.strip() for line in in_file)
    lines = (line.split(",") for line in stripped if line)
    with open('log.csv', 'w') as out_file:
        writer = csv.writer(out_file)
        writer.writerow(('title', 'intro'))
        writer.writerows(lines)
Posted by: Guest on January-23-2021

Code answers related to "convert a text file data to dataframe in python without pandas"

Python Answers by Framework

Browse Popular Code Answers by Language