[Tutor] Merging Text Files
Emile van Sebille
emile at fenx.com
Thu Oct 14 17:35:56 CEST 2010
On 10/14/2010 7:48 AM Ara Kooser said...
> Morning all,
>
> I took the pseudocode that Emile provided and tried to write a python
> program. I may have taken the pseudocode to literally.
>
> So what I wrote was this:
> 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 = proteinVals.split()[1]
> rslt = "%s,%s"% (line,PIDS[ID])
> print rslt
Without reading much further, what happens when you use the loop
variable here instead of the prio loop variable?
Change the second line to
ID = line.split()[1]
and see what you get.
Emile
More information about the Tutor
mailing list