
python如何读取CSV文件?下面给大家带来三种不同的方式:
普通方法读取:
with open("fileName.csv") as file:
for line in file:
print line用CSV标准库读取:
import csv
csv_reader = csv.reader(open("fileName.csv"))
for row in csv_reader:
print row用pandas读取:
立即学习“Python免费学习笔记(深入)”;
import pandas as pd
data = pd.read_csv("fileName.csv")
print data
data = pd.read_table("fileName.csv",sep=",")
print data
python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号