In [2]:
import pandas

In [3]:
%cd D:\free40


D:\free40

In [4]:
import glob
from os import path

In [5]:
files = glob.glob("*.txt")

In [6]:
valid_ids=[ 93, 143, 144, 182, 207, 232, 310, 325, 326, 330, 332, 374, 383, 399, 413, 414, 544, 545, 556, 566, 567, 595, 599, 600, 610, 616, 625, 789, 790, 806, 813, 815, 823, 906, 911, 912, 913, 939, 1006, 1221, 1232, 1249, 1253, 1258, 1267, 1286, 1300, 1326, 1339, ]

In [7]:
missing = {}

In [8]:
for f0 in files:
    f1=".".join(f0.split(".")[:-1]+["xlsx"])
    table = pandas.read_table(f0,index_col=0)
    index2=[int(i.rstrip("/")) for i in table.index]
    table.index=index2
    missing[f0]=set(valid_ids)-set(table.index)
    table2 = table.loc[valid_ids]
    table2.to_excel(f1)

In [9]:
for k,v in sorted(missing.items(),key=lambda x:x[0].split(".")[1]):
    print "%s\t%d\t%s\n\n"%(k, len(v), sorted(v))


rh.BA.area.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


lh.BA.volume.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


lh.BA.thickness.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


lh.BA.area.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


rh.BA.meancurv.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


lh.BA.meancurv.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


rh.BA.volume.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


rh.BA.thickness.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


lh.a2009s.volume.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


lh.a2009s.thickness.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


rh.a2009s.volume.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


rh.a2009s.thickness.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


rh.a2009s.area.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


lh.a2009s.meancurv.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


lh.a2009s.area.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


rh.a2009s.meancurv.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


aparc_volume_rh.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


aseg_stats.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


aparc_area_rh.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


aparc_thickness_rh.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


aparc_thickness_lh.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


aparc_meancurv_rh.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


wmparc_stats.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


aparc_volume_lh.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


aparc_meancurv_lh.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]


aparc_area_lh.txt	8	[332, 383, 599, 600, 616, 625, 1006, 1286]



In [ ]: