将csv文件导入python并在python中创建表

时间:2016-03-15 15:17:01

标签: python csv

我想将csv文件导入python,然后在python中创建一个表来显示导入的csv文件的内容。 还需要对表中的数据进行操作。 应该进一步执行与python中的表相关的更多函数: 喜欢: 1)使用python突出显示指定的列 2)使用特定列进行修改,例如使用python

按日期或数量排序数据

1 个答案:

答案 0 :(得分:0)

如果要使用Python导入csv文件或txt文件,这是一个示例。 我使用Numpy来实现:

#!/usr/bin/env python

import numpy as np

file = np.loadtxt('filename', delimiter=',') # Put the delimiter type from your csv file : coma, blank, ..

print file # print the numpy array

如果要在数组中进行排序,可以使用numpy函数:

np.sort()

Doc是there

现在,尝试制作一些东西,因为在发布问题之前获取脚本很重要;)