I would like to parse tab separated .txt files separating common attribute and distinct attribute from the file. I would like to parse only the first line attributes not the values. Could you please rectify this script. The file may be located from this url -
ftp://ftp.ebi.ac.uk/pub/databases/mi...MX-10.sdrf.txt
The source code i have written is as below -
ftp://ftp.ebi.ac.uk/pub/databases/mi...MX-10.sdrf.txt
The source code i have written is as below -
Code:
#!/usr/bin/python import glob outfile = open('output_attribute.txt' , 'w') files = glob.glob('*.sdrf.txt') for file in files: infile = open(file) #ret = False for line in infile: lineArray = line.split('\t') if '\n\n' in line: ret = false outfile.write('') break; elif len(lineArray) > 2: output = "%s\t%s\n\n"%(lineArray[0],lineArray[1]) outfile.write(output) else: output = "%s\t\n"%(lineArray[0]) outfile.write(output) infile.close() outfile.close()
Comment