tee chwee liong wrote:
modified the code to be but it didnt print out anything:
That is because your list of values is empty.
You have to collect the values, like your previous code did. *Then*
process them. In the code below, you try to process values before you
have any.
from __future__ import with_statement
def main():
rows = []
counter=1 #count row numbers
values = []
with open('test2.txt') as f:
for i in range(0,len(values),128):
#step through the list of values, starting at 0,
#taking 128 items at a time
temp=values[i:i+128]
#join the values into a string
s=''.join(temp)
#and make a row with a label.
values.append(line.rstrip('\n')[-1])
row = "Row" + str(counter) + " = " + s
print row
rows.append(row)
--
Steven
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor