0
我与数据CVS文件看起来像:如何在一定的csv文件列读取(上下)的Python
lastname firstname id
segre alberto 14562
我需要阅读与ID号 一切的专栏中,我尝试不断给我的行不是csv文件的列
我与数据CVS文件看起来像:如何在一定的csv文件列读取(上下)的Python
lastname firstname id
segre alberto 14562
我需要阅读与ID号 一切的专栏中,我尝试不断给我的行不是csv文件的列
import csv
import operator
idgetter = operator.itemgetter(2)
with open('path/to/file') as infile:
infile.readline()
ids = [idgetter(row) for row in csv.reader(infile)]
你可以使用熊猫。
import pandas as pd
col = pd.read_csv('/path/to/file/')['id']
如果你想把它当作一个列表,只需list(col)
会做的伎俩。