I have been learning python for a week. but I'm not sure how I can save the result as a file.
def process_rows(self, rows):
for row in rows:
self.rownum+=1
print(rownum)
I think there will be over 400000 results. But Termial shows only 8000 results from 441810 to 450000.
I wanna save the result on a .txt file and read. I have changed my code as follows.
def process_rows(self, rows):
f = open("output_file", 'a+')
for now in rows:
self.rownum +=1
f.write(rownum + "\n")
f.close()
But exception error has occurred.
TypeError: unsupported operand type(s) for +: 'int' and 'str'
ERROR:tornado.application:Uncaught exception in /conn
File "/usr/lib/python2.7/dist-packages/tornado/websocket.py", line 415, in _run_callback
callback(*args, **kwargs)
File "server.py", line 98, in process_rows
f.write(rownum + "\n")
NameError: global name 'rownum' is not defined