📜  在没有熊猫的情况下将文本文件数据转换为python中的数据框 - Python代码示例

📅  最后修改于: 2022-03-11 14:46:04.225000             🧑  作者: Mango

代码示例1
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)