Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread Bharathi Subramanian
> 2. If I have the C_ID of the customers in a separate csv, is it > possible to compare the C_ID with that of the C_ID in the dump and > determine the sum of stat1, vol2, amount3…  (sum of the fields > only for a set of customers and not for the ID_NOs in whole) If you looking for throw away scr

Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread Kumar Appaiah
On Tue, Nov 03, 2009 at 07:45:42PM +0530, steve wrote: >> f = open('Customer_IDs', 'r') >> customer_ids = f.read().strip().split('\n') # Assuming each ID is present in >> a separate line. >> > small bug in the line above. The line above only strip()s the last > newline. So, all lines except the l

Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread Shakthi Kannan
Hi, --- On Tue, Nov 3, 2009 at 3:58 PM, Raman.P wrote: | require DBI; \-- Also to include: use strict; use warnings; --- |           my $dbh = DBI->connect("DBI:CSV:"); \-- Need to always check for connection failure: my $dbh = DBI->connect( "DBI:CSV:" ) or die "Couldn't connect to

Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread Raja Subramanian
On Tue, Nov 3, 2009 at 11:40 PM, Shakthi Kannan wrote: > Need to always check for connection failure: > >  my $dbh = DBI->connect( "DBI:CSV:" ) >    or die "Couldn't connect to database: " . $dbh->errstr; Or be lazy and use RaiseError and get DBI to automatically die whenever any method fails. h

Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread steve
On 11/03/2009 06:54 PM, Kumar Appaiah wrote: On Tue, Nov 03, 2009 at 12:57:40PM -, Siva Subramanian wrote: [...snip...] 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

Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread steve
Hi Siva, On 11/03/2009 06:27 PM, Siva Subramanian wrote: Thanks Steve and Raman Found a better alternative. Python. :) Excellent !! I debated with myself whether I should just recommend python before I sent out my reply and finally decided against it (or at least defer suggesting it until/

Re: Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread Raja Subramanian
On Tue, Nov 3, 2009 at 6:27 PM, 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 Insert all Customer IDs into a new hash tabl

Re: Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread Kumar Appaiah
On Tue, Nov 03, 2009 at 12:57:40PM -, 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 ha

Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread Kenneth Gonsalves
On Tuesday 03 Nov 2009 6:27:40 pm Siva Subramanian wrote: > Thanks Steve and Raman Found a better alternative. Python. :) > I thought of suggesting that ... -- regards kg http://lawgon.livejournal.com ___ To unsubscribe, email ilugc-requ...@ae.iitm.ac

Re: Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread Siva Subramanian
Thanks Steve and Raman Found a better alternative. Python. :) import csv ifileR25 = open('Report_2_5, "rb") readerR25 = csv.reader(ifileR25) rownum = 0 for row in readerR25: if rownum == 0: header = row else: colnum = 0 for col in row: if rownum > 1: if colnum == 0: << do all my proce

Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread steve
Hi, On 11/03/2009 02:50 PM, Siva Subramanian wrote: Hello, I am into my 1st BSc Statistics and into a project for an MNC. I am trying my first hand at linux and was recently introduced to gawk. Welcome to linux ! I hope your experience is pleasant and you're here to stay :) I am having tro

Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread Raman.P
--- On Tue, 3/11/09, Raman.P wrote: > > There are specialised modules for csv at cpan.org. Million > records should not be a problem at all. > http://search.cpan.org/~adamk/Parse-CSV-1.00/lib/Parse/CSV.pm seems to be tuned for large files Raman.P blog:http://ramanchennai.wordpress.com/

Re: [Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread Raman.P
--- On Tue, 3/11/09, Siva Subramanian wrote: > I am into my 1st BSc Statistics and into a project for an > MNC. I am > trying my first hand at linux and was recently introduced > to gawk. > > > > I am having trouble processing a statistical dump that is > provided to us in the > form of a csv

[Ilugc] gawk query - csv processing. moving away from MS-Access

2009-11-03 Thread Siva Subramanian
Hello, I am into my 1st BSc Statistics and into a project for an MNC. I am trying my first hand at linux and was recently introduced to gawk. I am having trouble processing a statistical dump that is provided to us in the form of a csv file. The format of the file is given below C_ID,