Skip to content

Commit 498d3db

Browse files
committed
solve the new line problem in csv file
1 parent eea4832 commit 498d3db

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

python_csv/append_function.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def get_length(file_path):
1111
def append_data(file_path, name, email):
1212
fieldnames = ['id', 'name', 'email']
1313
next_id = get_length(file_path)
14-
with open('data.csv', 'a') as csvfile:
14+
with open('data.csv', 'a', newline='') as csvfile:
1515
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
1616
writer.writeheader()
1717
writer.writerow({

0 commit comments

Comments
 (0)