【发布时间】:2014-05-29 09:18:48
【问题描述】:
我的目的是从多个数据文件中提取某一列。 因此,我尝试使用 glob 模块读取文件,并尝试使用如下 for 语句从每个文件中提取一列:
filin = diri + '*_7.txt'
FileList=sorted(glob.glob(filin))
for INPUT in FileList:
a = []
b = []
c = []
T = []
f = open(INPUT,'r')
f.seek(0,0)
for columns in ( raw.strip().split() for raw in f):
b.append(columns[11])
t = np.array(b, float)
print t
t = list(t)
T = T + [t]
f.close()
print T
我使用的数据文件数量是 32。所以,我预计第二个“for”语句只运行了 32 次,同时只生成了 32 个 t 数组。但是,结果看起来不像我预期的那样。 我认为这可能是由于第一个“for”语句的影响,但我不确定。 任何想法或帮助将不胜感激。 谢谢, 艾萨克
【问题讨论】: