Reading and Writing CSV File

Reading and Writing CSV File:



comma-separated values (CSVfile is a delimited text file that uses a comma to separate values. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format. A CSV file typically stores tabular data (numbers and text) in plain text, in which case each line will have the same number of fields.



import pandas as pd

- Reading data from CSV file to a data frame:

df = pd.read_csv('file_name.csv')

- Saving data frame into csv file:

df.to_csv('file_name.csv', header=False, index=False)


Comments