好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

python怎么读csv文件

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读取:

import pandas as pd
data = pd.read_csv("fileName.csv")
print data
data = pd.read_table("fileName.csv",sep=",")
print data 

以上就是python怎么读csv文件的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于python怎么读csv文件的详细内容...

  阅读:50次