Why do I get:
Traceback (most recent call last):
File "./2csvtbl.py", line 31, in <module>
print row[k], row[-k]
IndexError: list index out of range
after running this code:
#!/usr/bin/env python
import csv
import random
alpha = 'abcdefghijklmnopqrstuvwxyz'
e = range(0,99)
x = random.sample(alpha,14)
y = random.sample(e,14)
c = csv.writer(open("test2.csv", "wb"))
c.writerow([x])
cr = csv.reader(open("test2.csv","rb"))
for row in cr:
print row[1], row[1]
print "How many rows?"
l = input()
k = 1
while k < int(l):
c = csv.writer(open("test.csv", "wb"))
c.writerow([y])
cr = csv.reader(open("test.csv","rb"))
for row in cr:
k +=1
print row[k], row[-k]
print "done"