import csv
# open the file
with open('csvfile.csv' , 'r') as csvfile:
# create the object of csv.reader()
csv_file_reader = csv.reader(csvfile,delimiter=',')
for row in csv_file_reader:
print(row)
# importing Pandas library
import pandas as pd
pd.read_csv(filepath_or_buffer = "pokemon.csv")
# makes the passed rows header
pd.read_csv("pokemon.csv", header =[1, 2])
# make the passed column as index instead of 0, 1, 2, 3....
pd.read_csv("pokemon.csv", index_col ='Type')
# uses passed cols only for data frame
pd.read_csv("pokemon.csv", usecols =["Type"])
# returns pandas series if there is only one column
pd.read_csv("pokemon.csv", usecols =["Type"],
squeeze = True)
# skips the passed rows in new series
pd.read_csv("pokemon.csv",
skiprows = [1, 2, 3, 4])
import csv
def read_csv(path):
with open(path, 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
print("Row is: ",row)
read_csv(your_file_path)