realtime output and csv files

Tim Chase python.list at tim.thechases.com
Fri Feb 5 23:27:15 EST 2016


On 2016-02-05 17:57, Bernardo Sulzbach wrote:
> CSVs is essentially text separated by commas, so you likely do not
> need any library to write it "Just separating with ','" should work
> if you are formatting them correctly.

> https://mail.python.org/mailman/listinfo/python-list
And even if you have things to escape or format correctly, the stdlib
has a "csv" module that makes this trivially easy:

  data = [
    (1, 3.14, "hello"),
    (2, 1.41, "goodbye"),
    ]
  from csv import writer
  with open("out.csv", "wb") as f:
    w = writer(f)
    w.writerows(data)
    # for row in data:
    #     w.writerow(data)

-tkc



More information about the Python-list mailing list