[Ilugc] using dictreader in python

  • From: rajasuperman@xxxxxxxxx (Raja Subramanian)
  • Date: Tue Nov 10 16:47:19 2009

On Tue, Nov 10, 2009 at 3:42 PM, Siva Subramanian <neuphyte@xxxxxxxxx> wrote:

Thanks a lot. It works like a breeze when the files are small (< 100MB)

However, it takes a jolly good 45 mins on a desktop with 2 GB of memory and
3.2 G P4

The code i am using is given below,

import csv
readerR25 = csv.reader(open('report_2_5.csv', "rb"))

Change this line:

cids = [line.strip() for line in open('prov_30.csv')]

with:

cids = {}
cids.fromkeys([line.strip() for line in open('prov_30.csv')])

and see if it makes the code run any faster.

- Raja

Other related posts: