Soroush Ghodsi
Soroush Ghodsi

Reputation: 380

Create a new CSV File?

I'm looking to create a new .csv file using python and then write to the file after that. I couldn't find a command to create a new file using the CSV library. I thought something like

NewFile = csv.creatfile(PATH)

might exist but I couldn't find something like that.

Thank you in advance! Happy to answer any questions you may have!

Upvotes: 0

Views: 227

Answers (1)

nthall
nthall

Reputation: 2915

The csv module doesn't handle file creation; Python handles file creation as a builtin function called open -- once you have a file handle created using open, you can use it with csv.writer or csv.DictWriterto write data to the file.

Upvotes: 3

Related Questions