to read csv file in python code example
Example 1: python read csv
import pandas as pd
data = pd.read_csv('data.csv')
print(data)
Example 2: read csv python
import pandas as pd
data = pd.read_csv("filename.csv")
data.head()
Example 3: python csv
>>> import csv
>>> with open('names.csv', newline='') as csvfile:
... reader = csv.DictReader(csvfile)
... for row in reader:
... print(row['first_name'], row['last_name'])
...
Eric Idle
John Cleese
>>> print(row)
{'first_name': 'John', 'last_name': 'Cleese'}