Home > other >  Python regularly read and write files previous line repeated 2945 more times
Python regularly read and write files previous line repeated 2945 more times

Time:09-15

I want to read a CSV file every 10 seconds, and then to modify a status symbol, and then write the file back to the CSV file, the file has other module in written)

Maybe because I next time this time I read, write, the content of the error hint I recursionerror: maximum recursion the depth exceeded the while calling a python object

How to solve this problem, don't read and write with the other methods to modify status flag?

Code is offline, is roughly like this:

Def timetask () :
A=pd. Read_csv (' path ')
A [' flag ']=1
A.t o_csv (' path)
Threading. The timer (10, timetask (), ()). The start ()

Threading. The timer (10, timetask (), ()). The start ()

CodePudding user response:

The CSV you read and write is the same file?

CodePudding user response:

reference 1st floor chuifengde response:
the CSV you read and write is the same file?


yes

CodePudding user response:

See hint is transfinite recursion depth, there is the threading, the timer (10, timetask (), ()) part in global variables, and then start (), you try it feasible

CodePudding user response:

reference chuifengde reply: 3/f
see tip is transfinite recursion depth, there is the threading, the timer (10, timetask (), ()) part in global variables, and then start (), you try is it feasible to


I tried, no

In fact, I don't know much about I didn't call itself, just read and write the same file, why be done recursively?

Tip is I read files repeated 2900 times the code, a=pd. Read_csv (" path ")
  • Related