Docsity

Csv file. Import export of dataframe, Schemes and Mind Maps of Computer science

Partial preview of the text

Download Csv file. Import export of dataframe and more Schemes and Mind Maps Computer science in PDF only on Docsity!

Chapter 4 : Import

Export Data

  • CSV to DataFrame
  • DataFrame to CSV

A CSV is a comma separated values file, which allows data to be saved in a tabular format. CSV is a simple file such as a spreadsheet or database. Files in the csv format can be imported and exported from programs that store data in tables, such as Microsoft excel or Open Office. CSV files data fields are most often separated, or delimited by a comma. Here the data in each row are delimited by comma and individual rows are separated by newline.

To create a csv file, first choose your favorite text editor such as- Notepad and open a new file. Then enter the text data you want the file to contain, separating each value with a comma and each row with a new line. Save the file with the extension.csv. You can open the file using MS Excel or another spread sheet program. It will create the table of similar data.

pd.read_csv() method is used to read a csv file.

Exporting data from dataframe to CSV File

To export a data frame into a csv file first of all,

we create a data frame say df1 and use

dataframe.to_csv(‘ E:\Dataframe1.csv ’ )

method to export data frame df1 into csv file

Dataframe1.csv.