2
我有CSV像蟒蛇CSV文件中查找文本,然后找到一个特定的列
apple,10,red,date
orange,12,yellow,date
pear,13,green,date
pineapple,14,brown,date
我想首先搜索如数据库:菠萝,然后得到第三列”,从它,我需要一些想法,我使用Python的CSV模块
我能够得到
#!/usr/bin/env python
import csv
import sys
file = open("/tmp/database.txt", 'rt')
reader = csv.reader(file)
for i in reader:
print i
输出:
['apple', '10', 'red', 'date']
['orange', '12', 'yellow', 'date']
['pear', '13', 'green', 'date']
['pineapple', '14', 'brown', 'date']
感谢phihag工作... – krisdigitx