How does python read CSV files? Here are three different ways for you:
Reading with normal method:
with open("fileName.csv") as file: for line in file: print line
Reading with CSV standard library:
import csv csv_reader = csv.reader(open("fileName.csv")) for row in csv_reader: print row
Read with pandas:
import pandas as pd data = pd.read_csv("fileName.csv") print data data = pd.read_table("fileName.csv",sep=",") print data
The above is the detailed content of How to read csv file in python. For more information, please follow other related articles on the PHP Chinese website!