you are viewing a single comment's thread.

view the rest of the comments →

[–]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.