xxxxxxxxxx
# pip install pandas
import pandas as pd
# Read the csv file
data = pd.read_csv('data.csv')
# Print it out if you want
print(data)
xxxxxxxxxx
import csv
with open('file_csv.csv', newline='') as file:
reader = csv.reader(file)
for row in reader:
print(row)
xxxxxxxxxx
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)
xxxxxxxxxx
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)
xxxxxxxxxx
import csv
with open('some.csv', newline='') as f:
reader = csv.reader(f)
for row in reader:
print(row)
xxxxxxxxxx
import csv
with open('filename.csv') as csvfile:
spamreader = csv.reader(csvfile)
for row in spamreader:
print(row)
xxxxxxxxxx
import pandas as pd # pip install pandas
#read the CSV file
data_file = =pd.read_csv('some_file.csv')
print(data_file)
xxxxxxxxxx
import pandas as pd
import numpy as np
datas = pd.read_csv('data.csv')
a = datas.to_numpy()
print(a[0])
xxxxxxxxxx
lines = [] # a list of lists, the first list being a header, and the rest being the data
with open("your_filename", newline='') as f:
file = csv.reader(f)
for each in file:
lines.append(each)
print(lines)