好的,所以我導入了一個CSV,然後我想將row[0]
中的所有迭代值與row[1]
中的迭代值合併。合併CSV中兩個不同列的所有值
csvfile = csv.reader(open(filename, 'rb'), delimiter=',')
for row in csvfile:
row[0] + row[1]
這樣,除了我希望所有的row[0]
值的與所有的row[1]
值的結合,即使他們不在同一行。
所以可以說我有兩列,一列是:
asparagus
beets
corn
cucumbers
tomatoes
,另一個是:
pineapple
orange
apple
raspberry
blueberry
我想有蘆筍所有列表2的組合,即:
asparagus pineapple
asparagus orange
asparagus apple
asparagus raspberry
asparagus blueberry
然後去甜菜菠蘿等
是的,但我的格式不在行= [[「blah」,「blah」,「blah」],[「two」,「two,」two「]] –
@AndrewAlexander恐怕我沒有你是否需要將每一對格式化爲一個字符串? –
那麼,我仍然需要遍歷整個列表,不是嗎? –