Dear,
I would like to parse only the first line of each adf.txt files (i.e. attributes) . This python code could print individually for each file type, but i would like to run in one python code for all adf.txt files where the first line starts with only 4 different attribute terms like 'Composite Element Name | Block Column | Reporter Name | CompositeSequen ce Identifier' for all 35 different adf.txt files. I hereby attached only a zip file for 4 adf.txt files but for more files you may locate at this link ftp://ftp.ebi.ac.uk/pub/databases/microarray/data/array Could you please rectify this script . I would be glad for your support and cooperation.
Regards,
Haobijam
I would like to parse only the first line of each adf.txt files (i.e. attributes) . This python code could print individually for each file type, but i would like to run in one python code for all adf.txt files where the first line starts with only 4 different attribute terms like 'Composite Element Name | Block Column | Reporter Name | CompositeSequen ce Identifier' for all 35 different adf.txt files. I hereby attached only a zip file for 4 adf.txt files but for more files you may locate at this link ftp://ftp.ebi.ac.uk/pub/databases/microarray/data/array Could you please rectify this script . I would be glad for your support and cooperation.
Code:
#!/usr/bin/python
import glob
#import linecache
outfile = open('out_att.txt' , 'w')
files = glob.glob('*.adf.txt')
for file in files:
infile = open(file)
#count = 0
for line in infile:
lineArray = line.rstrip()
if not line.startswith('Composite Element Name') : continue
#count = count + 1
lineArray = line.split('%s\t')
print lineArray[0]
output = "%s\t\n"%(lineArray[0])
outfile.write(output)
infile.close()
outfile.close()
Haobijam
Comment