Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON dump big list containing dict, text, datetime and ints gives "TypeError: 'str' does not support the buffer interface"

Using Python 3.2 64 bit on Windows 7 64 bit.

f = open("raw_data/results.json", "wb")
json.dump(dictio, f)
f.close()

Gives error:

Traceback (most recent call last):
  File ".\calc_stats_friendly_data.py", line 22, in <module>
    main()
  File ".\calc_stats_friendly_data.py", line 18, in main
    json.dump(races, f)
  File "C:\Python32\lib\json\__init__.py", line 179, in dump
    fp.write(chunk)
TypeError: 'str' does not support the buffer interface

I have no idea what goes wrong. Using pickle works fine! But I have to use JSON... Tips for finding the problem? The list is big. Saving it with pickle it takes 56 MB.

like image 786
slowkvant Avatar asked Dec 25 '12 15:12

slowkvant


1 Answers

You're opening the file for binary writing. Open it using "w" as a mode only.

like image 123
Ry- Avatar answered Nov 06 '22 23:11

Ry-