我有一个.txt文件,其中有三列。忽略python中的空值列
id ImplementationAuthority.email AssignedEngineer.email
ALU02034116 [email protected] [email protected]
ALU02035113 [email protected]
ALU02034116 [email protected] [email protected]
ALU02022055 [email protected]
ALU02030797 [email protected] [email protected]
我需要创建两个列表,其中包括执行Authority.mail和Assigned Engineer.mail列下的值。当列具有复合值时(即没有空值),它可以很好地工作。当列包含空值时,这些值会混合在一起。
aengg=[]
iauth=[]
with open('test.txt') as f:
for i, row in enumerate(f):
columns = row.split()
if len(columns) == 3:
aengg.append(columns[2])
iauth.append(columns[1])
print aengg
print iauth
我试过用这段代码,它完全适用于完整的列值。 任何人都可以请告诉我一个解决方案的空值?
请首先告诉我们您到目前为止尝试过什么? – GLHF 2014-12-19 06:01:29
@qqvc我更新了这个问题。 – WarriorPrince 2014-12-19 06:06:44
那么现在的输出是什么,以及预期的输出是什么。不能理解。我运行你的例子,它似乎工作。 – Marcin 2014-12-19 06:14:29