I'm getting the following error message:

      AttributeError: 'tuple' object has no attribute 'seek'

below is the code that produced the error.  The line in question is 
marked with arrow in the left margin.  Any help would be appreciated. 

def build_sp500_rand():
    sp500_csv = open('c:/indices/sp500.csv', 'r')
    sp500_csv_recs = sp500_csv.readlines()
    sp500_csv.close()
   
    sp_rand = ('c:/indices/sp500.rnd', 'w+b')
    record_size  = struct.calcsize('Lf')

    record_number = 0
    for rec in sp500_csv_recs:
        rec.strip('\n')
        sp500_csv_fields = rec.split(',')
       
       
        sp500_csv_date = sp500_csv_fields[0]
        sp500_csv_open = sp500_csv_fields[1]
        sp500_csv_high = sp500_csv_fields[2]
        sp500_csv_low = sp500_csv_fields[3]
        sp500_csv_close = sp500_csv_fields[4]
        sp500_csv_volume = sp500_csv_fields[5]
       
        print 'build:', sp500_csv_date
       
        buffer = struct.pack('Lf', long(sp500_csv_date), 
float(sp500_csv_close))
====>   sp_rand.seek(record_number * record_size)
        sp_rand.write(buffer)
       
        record_number = record_number + 1
       
    sp_rand.close()




-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.10/43 - Release Date: 7/6/2005

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to