码迷,mamicode.com
首页 > 其他好文 > 详细

读入文件

时间:2016-01-09 13:42:37      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

python本身方法:

f=open("xx.csv","r")
b=f.read()
rows=b.split(\n)
full_data = []
for row in rows:
    cols_in_a_row=row.split(,)
    full_data.append(cols_in_a_row)

NumPy方法:

import numpy
# Note that we don‘t need to use the open function to open it -- numpy will take care of that.
# numpy.ndarray
nfl = numpy.genfromtxt("nfl.csv", delimiter=",",dtype="U75", skip_header=1)

Pandas方法:

import pandas
# DATAFRAME
housing_2013 = pandas.read_csv("Hud_2013.csv")

 

读入文件

标签:

原文地址:http://www.cnblogs.com/arsh/p/5115503.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!