How to create blank csv file in pandas?

0 votes

Hi. I am written a python script to write data in a csv file. There’s a part in the script that checks if the file exists, and if it doesn’t exist, it creates a blank csv file. I am not understanding how to implement this, please help.

Apr 5 in Python by Raj
535 views

1 answer to this question.

0 votes

Try this code:

open("User data.csv", 'w')

Where User data.csv is your file name

answered Apr 5 by Will

Related Questions In Python

0 votes
2 answers

How to check if a csv file is empty in pandas?

Try this: df = pd.DataFrame(columns=['Name', 'ID', 'Department']) if df.empty ...READ MORE

answered Jul 1 in Python by Bob
252 views
0 votes
1 answer

How to create LIST from CSV file in Python?

You can use the pandas library for this which ...READ MORE

answered Jul 15 in Python by Karan
29 views
0 votes
1 answer

How to create and read from a temporary file in Python?

Hi, there is a very simple solution ...READ MORE

answered Jan 29 in Python by Nymeria
• 3,520 points
67 views
0 votes
1 answer

How to read Pandas csv file with no header?

You can set the header option to ...READ MORE

answered Apr 3 in Python by Shri
426 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 232 views
+4 votes
6 answers
0 votes
1 answer

How to create empty pandas dataframe only with column names?

You can do it like this: df=pd.DataFrame(columns=["Name","Old","New ...READ MORE

answered Apr 5 in Python by Hari
121 views
0 votes
1 answer

How to create Pandas dataframe from Python list?

You can do it like this: import ...READ MORE

answered Apr 5 in Python by Likhita
58 views