Read extra comma while exporting to csv

is there any method read extra comma while exporting Data frame to CSV file??

1 Like

@kantamaneni024 Please mention your batch. To save DataFrame in CSV try following command df.to_csv(“FileName.csv”, quotechar =" ’ ").

1 Like

When exporting a DataFrame to a CSV file using pandas in Python, by default, extra commas are not added between columns. The DataFrame is written to the CSV file in a structured format with each column separated by a comma.

Here’s an example of exporting a DataFrame to a CSV file using pandas:
import pandas as pd

Create a sample DataFrame

data = {‘Name’: [‘John’, ‘Jane’, ‘Mike’],
‘Age’: [25, 30, 35],
‘City’: [‘New York’, ‘London’, ‘Paris’]}
df = pd.DataFrame(data)

Export DataFrame to CSV file

df.to_csv(‘data.csv’, index=False)

In this example, the DataFrame df is exported to a CSV file named “data.csv” using the to_csv function. The index=False parameter is used to exclude the index column from being written to the CSV file.

The resulting CSV file will have the following content:

John,25,New York