1# pip install pandas
2import pandas as pd
3
4# Read the csv file
5data = pd.read_csv('data.csv')
6
7# Print it out if you want
8print(data)
1# This action requires the 'csv' module
2import csv
3
4# The basic usage is to first define the rows of the csv file:
5row_list = [["SN", "Name", "Contribution"],
6 [1, "Linus Torvalds", "Linux Kernel"],
7 [2, "Tim Berners-Lee", "World Wide Web"],
8 [3, "Guido van Rossum", "Python Programming"]]
9
10# And then use the following to create the csv file:
11with open('protagonist.csv', 'w', newline='') as file:
12 writer = csv.writer(file)
13 writer.writerows(row_list)
14# This will create a csv file in the current directory
1import pandas as pd # pip install pandas
2
3#read the CSV file
4data_file = =pd.read_csv('some_file.csv')
5print(data_file)
6
1import csv
2
3with open('employee_birthday.txt', mode='r') as csv_file:
4 csv_reader = csv.DictReader(csv_file)
5 line_count = 0
6 for row in csv_reader:
7 if line_count == 0:
8 print(f'Column names are {", ".join(row)}')
9 line_count += 1
10 print(f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.')
11 line_count += 1
12 print(f'Processed {line_count} lines.')
13
1import csv
2
3f = open("fileName.csv") # encoding="utf8"
4reader = csv.DictReader(f) # delimiter=";", quotechar='"'
5data = [row for row in reader]
6
1import pandas as pd
2import numpy as np
3datas = pd.read_csv('data.csv')
4a = datas.to_numpy()
5print(a[0])