python - csv reader mismatch in rows values -


i writing python script data csv file using python csv reader , loading database. problem rows have 3 columns out of twenty four.

my code:

spamreader = csv.reader(filename, delimiter='|') n=0 row in spamreader:     n += 1     if n>2:          if len(row)>1:             if str(row[0]).strip():                 data1 =  str(row[0]).strip()              else :                  data1 = ""             if str(row[1]).strip():                 data2 =  str(row[1]).strip()              else :                  data2 = ""             dataload =datafromcsv(data1=data1,data2=data2,...data24=data24)             dataload.save() 

   spamreader = csv.reader(filename, delimiter='|')    next(spamreader) # skip first line    row in spamreader:         if len(row)>1:             data = [str(r).strip() if r else "" r in row]    .... 

Comments