[Tutor] Merging Text Files
Ara Kooser
ghashsnaga at gmail.com
Thu Oct 14 22:44:45 CEST 2010
Hey all,
It's mostly solved. The program prints out to the screen just fine except
for the new line return. Here is what I ended up using:
########
#Merges two files into one using dictionaries
########
xml = open("final.txt",'r')
gen = open("final_gen.txt",'r')
PIDS = {}
for proteinVals in gen:
ID = proteinVals.split(',')[0]
PIDS[ID] = proteinVals
print PIDS
for line in xml:
ID = line.split(',')[1]
IDs = ID.strip()
rslt = "%s,%s"% (line,PIDS[IDs])
print rslt
When I write this to a file what's the best way to take out the new line?
Thanks again for everyone's help and pseudocode. It's been about 4 years
since my last programming project!
ara
--
Quis hic locus, quae regio, quae mundi plaga. Ubi sum. Sub ortu solis an sub
cardine glacialis ursae.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101014/58a32dbc/attachment.html>
More information about the Tutor
mailing list