Carlos-Francisco Méndez-Cruz

Transform soft file in XML file

...@@ -98,13 +98,13 @@ if __name__ == "__main__": ...@@ -98,13 +98,13 @@ if __name__ == "__main__":
98 hashGcs[serie][sample][tag] = [content] 98 hashGcs[serie][sample][tag] = [content]
99 #print("New tag: {} and content: {}".format(tag, content.encode(encoding='utf-8', errors='replace'))) 99 #print("New tag: {} and content: {}".format(tag, content.encode(encoding='utf-8', errors='replace')))
100 # print(hashGcs) 100 # print(hashGcs)
101 - tags = ["Technique", "Orgn", "Strain", "Substrain", "Gversion", "Gtype", "Phase", "Phase", "Air", "Med", "Temp", "Supp"] 101 + tags = ["Technique", "Orgn", "Strain", "Substrain", "Gversion", "Gtype", "Phase", "Air", "Med", "Temp", "Supp", "pH", "Press", "OD", "Rate", "Vess", "Agit", "Name", "Anti"]
102 #with open(os.path.join(options.outputPath, f.replace(".xml", ".report.csv")), "w", encoding="utf-8") as oFile: 102 #with open(os.path.join(options.outputPath, f.replace(".xml", ".report.csv")), "w", encoding="utf-8") as oFile:
103 with open(os.path.join(options.outputPath, f.replace(".xml", ".report.csv")), "w") as oFile: 103 with open(os.path.join(options.outputPath, f.replace(".xml", ".report.csv")), "w") as oFile:
104 - output = 'Serie\tSample\t' 104 + output = '"Serie","Sample",'
105 for tag in tags: 105 for tag in tags:
106 - output = output + tag + '\t' 106 + output = output + '"' + tag + '",'
107 - output = output.rstrip('\t') 107 + output = output.rstrip(',')
108 oFile.write(output + "\n") 108 oFile.write(output + "\n")
109 for serie, hashSample in hashGcs.items(): 109 for serie, hashSample in hashGcs.items():
110 print("Serie: {}".format(serie)) 110 print("Serie: {}".format(serie))
...@@ -117,10 +117,10 @@ if __name__ == "__main__": ...@@ -117,10 +117,10 @@ if __name__ == "__main__":
117 else: 117 else:
118 pTags.append('') 118 pTags.append('')
119 119
120 - output = '{}\t{}\t'.format(serie, sample) 120 + output = '"{}","{}",'.format(serie, sample)
121 for tag in pTags: 121 for tag in pTags:
122 - output = output + tag + '\t' 122 + output = output + '"' + tag + '",'
123 - output = output.rstrip('\t') 123 + output = output.rstrip(',')
124 oFile.write(output + "\n") 124 oFile.write(output + "\n")
125 # oFile.write("{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n".format(sample, serie, Technique, Orgn, Strain, Substrain, Gversion, Gtype, Phase, Air, Med, Temp, Supp)) 125 # oFile.write("{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n".format(sample, serie, Technique, Orgn, Strain, Substrain, Gversion, Gtype, Phase, Air, Med, Temp, Supp))
126 # for tag, listContent in sorted(hashTag.items()): 126 # for tag, listContent in sorted(hashTag.items()):
......