On Tue, Nov 03, 2009 at 12:57:40PM -0000, Siva Subramanian wrote:
> The trouble's different. How do i open two files, the Report_2_5
> above and also another one with the Customer IDs alone and look for
> rows only for in Report_2_5 for it and process them alone
>
> for example,
>
> Report_2_5 has the following data
> C_ID, ID_NO, stat1, vol2, amount3
> 2134, Ins1, 10000, 20000, 10
> 2112, Ins3, 30000, 20000, 10
> 2121, Ins3, 30000, 20000, 10
> 2145, Ins2, 15000, 10000, 5
> 2245, Ins2, 15000, 10000, 5
> 0987, Ins1, 10000, 20000, 10
>
> Now my customer id has the following records ONLY
> 2134
> 0987
>
> Should i iterate through the complete customer id file to find out if a
> number is there ? if so, how do i create a report of just the following and
> process it ?
> C_ID, ID_NO, stat1, vol2, amount3
>
> 2134, Ins1, 10000, 20000, 10
>
> 0987, Ins1, 10000, 20000, 10
>
>
> My output has to state
>
> Stat1 : 20000
> vol2 : 40000
> amount3 : 20
The following code reads the customer numbers alone:
f = open('Customer_IDs', 'r')
customer_ids = f.read().strip().split('\n') # Assuming each ID is present in a
separate line.
Then, in your previous program, print only if the customer ID belongs
to one the above list, i.e.
if customer_id in customer_ids:
print ...
etc.
HTH.
Kumar
--
Kumar Appaiah
_______________________________________________
To unsubscribe, email [email protected] with
"unsubscribe <password> <address>"
in the subject or body of the message.
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc