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, 2019 in Python by Raj
1,078 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, 2019 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, 2019 in Python by Bob
1,123 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, 2019 in Python by Karan
365 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, 2019 in Python by Nymeria
• 3,520 points
119 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, 2019 in Python by Shri
3,695 views
0 votes
1 answer
+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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 539 views
0 votes
0 answers
+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, 2019 in Python by Hari
1,647 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, 2019 in Python by Likhita
129 views