[Tutor] Merging Text Files
Ara Kooser
ghashsnaga at gmail.com
Thu Oct 14 21:17:33 CEST 2010
Adam,
I am going to try and sort through the pseudocode you provided to see if
I can get things up and running that way has well. This a part of a larger
workflow thing and needs to be in the format that I have. Sticking all this
into a database is down the road a ways.
*for every line in ONE:*
* make a dictionary with a key = to the protein ID and the value, the
rest*
I am pretty sure I have this correct by doing this:
xml = open("final.txt",'r')
gen = open("final_gen.txt",'r')
PIDS = {}
for proteinVals in xml:
ID = proteinVals.split()[0]
PIDS[ID] = proteinVals
print PIDS
For this part:
*for every line in TWO:*
* if the dictionary has the same protein ID:*
* perform the string merging and write to the file*
For this part I would need to do something like:
for line in gen:
ID = proteinVals.split()[0]
if ID in PIDS: (I need to check for the key?)
???How do you merge lines being read in to a previous dictionary
else:
move on to next number
Thanks!
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/cc4ed25d/attachment.html>
More information about the Tutor
mailing list