CSV FILE Comma separated value file… Here is where our class begins…
WHAT IS A CSV file ? 01. HOW TO CREATE A CSV file ? 02. REPRESENTATION OF CSV ON MS-word and ms -excel… 03. Reading a csv file ? 04. EXPORTING DATA FROM DF. TO CSV file… 05. ADVANTAGES OF CSV… 06. TABLE OF CONTENTS
W hat is a csv ? CSV Files CSV stands for Comma Separated Values. It is used for storing tabular data in a spreadsheet or a database. Each record consists of fields(cols) separated by commas (delimiter). Each line of a file is called a record. To create a new row we can easily press enter and move to the another line.
HOW TO CREATE A CSV ? To create a csv file, first choose your favorite text editor such as- MS-WORD a nd 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.
Csv file created on ms -word…
Csv file created on ms -excel…
Reading a csv file ? To read a csv file in DF. the below Syntax is used: INPUT DF= pd.read_csv (file path) OUTPUT
EXPORTING DATA FROM DF. TO CSV… To export a data frame into a csv file first of all, we create a data frame say df1. USE SYNTAX : dataframe.to_csv (‘ E:\Dataframe1.csv ’) To export data frame df1 into csv file Dataframe1.csv.
And now the content of df1 is exported to csv file Dataframe1.
Advantages of CSV File Easier to create. Preferred import and export format for databases and spreadsheets (Tabular Form). Capable of storing large amount of data (Tabular Form). CSV is faster to handle.