I had a doubt on how to create an empty csv file where I can open it later to save some data using python. How do I do it? Thanks
An empty csv file can be created like any other file - you just have to perform any operation on it. With bash, you can do touch /path/to/my/file.csv
.
Note that you do not have to create an empty file for python to write in. Python will do so automatically if you write to a non-existing file. In fact, creating an empty file from within python means to open it for writing, but not writing anything to it.
with open("foo.csv", "w") as my_empty_csv:
# now you have an empty file already
pass # or write something to it already
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With