我有以下格式的文本文件:
1,"20130219111529","90UP:34","0000","9999","356708","2"
"-2","20130219105824","0001:11","0000","","162_005",""
我想出于某种目的比较第 1 行和第 2 行(在本例中为 1 和 -2)。要删除所有引号并解析此文件,我有以下代码:
if os.path.exists(FileName):
with open(FileName) as File:
for row in csv.reader(File, delimiter= ',', skipinitialspace= True):
print(row)
以下是输出:
['1', '20130219111529', '90UP:34', '0000', '9999', '356708', '2']
['-2', '20130219105824', '0001:11', '0000', '', '162_005', '']
我想遍历列。例如,遍历 '1' 然后 '-2' 等等。
我该怎么做呢?