简体   繁体   中英

Exporting Python output for a text/ csv file [on hold]

I have a Python output which contains nearly 3.5 million rows. I need to import it to a csv/ text file.

Please help

If it's a console output you can do it through terminal or command prompt

python script.py > output.txt
import csv

with open('my_file.csv', 'w') as my_file:
    my_writer = csv.writer(my_file, delimiter=',')
    my_writer.writerows(rows)

Where variable rows corresponds to your Python output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM