sys.stdout.flush() # Read in data from SNP file and create insert statements with open(curSnpFilePath,'r') as csvfile: data = csv.reader(csvfile,delimiter='\t') for row in data: if(len(row) == 3): hasSig = False if row[2] != '' and row[2] != 'false': hasSig = True rsidList[row[0]] = 0 insStr = "INSERT INTO snp (rsid, chr, has_sig) VALUES ('{0}', '{1}', {2}) RETURNING id".format(row[0], row[1], hasSig) snpInserts[row[0]] = insStr # Data for reporting result.snpLoadEnd = time.time() result.totalSnps = len(snpInserts) # Insert SNP data into postgres cursor = postgresConnection.cursor() print "Chromosome " + str(curChr) + ". Inserting SNP Data." sys.stdout.flush() # Log current run start time result.snpInsertStart = time.time() # For each snp, insert record and then grab primary key for rsid,snp in snpInserts.iteritems(): cursor.execute(snp) rsidList[rsid] = cursor.fetchone()[0]