The read_csv()
function in pandas helps to read comma-separated values (CSV). It takes multiple arguments. We can simply pass a filename
to it, provided pandas code and content file are in the same directory. Otherwise, a complete directory with a file name are required such as: directory\FileName
i.e."C:\augmentedReality.csv"
.
import pandas as pd
dataFrame = pd.read_csv("path/filename.csv")
There are multiple parameters to this function. The following are some of the frequently used parameters.
Check out this link for the complete documentation.
filepath/buffer
:
A valid path or a URL, but should follow a valid URL schema, i.e., HTTP, FTP, file, etc.sep
: string, default (,).delimiter
: string, default (none).header
: int, list of int, default (first row as column names).names
: array (contains column names), optional.read.csv()
returns either a DataFrame
or a TextParser
. A CSV
file will be turned into a 2D data structure with labeled columns. If names
is supplied, labels will be as mentioned.
#Pandas read_csv() functionimport pandas as pddf = pd.read_csv("File.csv")print(df) #Print File.csv data on console