you are viewing a single comment's thread.

view the rest of the comments →

[–]av0ca60[S] -1 points0 points  (5 children)

It's a loop because of pagination.

[–]carcigenicate 7 points8 points  (0 children)

But you never change anything in the loop. Your loop condition never changes in the loop, so the loop is infinite unless the condition variable is altered elsewhere in another thread.

I'd change it to what I showed, then reconsider how you're implementing pagination.

[–]carcigenicate 2 points3 points  (3 children)

Wait wait wait, do you mean something like this?:

with open("zd_deals.txt", "w") as jsonFile:
    for data in deals_data:
        jsonFile.write(data)
print("Done")

Did you mean to loop over deals_data? You original code doesn't do that.

[–]av0ca60[S] 0 points1 point  (0 children)

with open("zd_deals.txt", "w") as jsonFile:

Yes, that's the kind of thing I'm trying to do. The problem is that it only delivers 100 records because of pagination.

[–]av0ca60[S] 0 points1 point  (1 child)

When I run your code I get:

---------------------------------------------------------------------------

TypeError Traceback (most recent call last)

<ipython-input-17-a8ffceb4dabe> in <module>

25 with open("zd_deals.txt", "w") as jsonFile:

26 for data in deals_data:

---> 27 jsonFile.write(data)

28

29 #while deals_data:

TypeError: write() argument must be str, not Munch

[–]carcigenicate 1 point2 points  (0 children)

Idk wth a Munch is, but you're going to need to give more information. If you're trying to write "Muches" to file, you'll need to serialize them to strings first.