[Tutor] how to read two files and substitute

Andre Engels andreengels at gmail.com
Tue May 17 16:09:00 CEST 2011


First read file1, and keep the result in a useful data structure (for
this simple case it can be nothing more than a dictionary with the
value in column 1 as key and the value in column 4 as value, but
perhaps it's better to find something else if you want to do more with
the data). Then go through file2, check your data structure for every
value, and ready.

André

On Tue, May 17, 2011 at 3:42 PM, lina <lina.lastname at gmail.com> wrote:
> Hi,
>
> For file1:
>
>  5007  O28 CHO   173      35.300  99.430  65.810  1.00  0.0
>  5008  H29 CHO   173      35.680 100.290  66.150  1.00  0.00
>  5009  C1  CHO   174      59.060  12.440  58.680  1.00  0.00
>  5010  C2  CHO   174      59.460  12.480  60.160  1.00  0.00
>  5011  C3  CHO   174      59.590  11.120  60.830  1.00  0.00
>  5012  C4  CHO   174      60.780  10.430  60.160  1.00  0.00
>
> For file2:
>
> 5008 5010 5011
>
> I want to get the $4(column 4) value which has  the $1 value. for
> values in file2
>
> such as the results is 173 174 174
>
> Thanks for any suggestions,
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
André Engels, andreengels at gmail.com


More information about the Tutor mailing list