Issue with special characters in API

Tags: #<Tag:0x00007fef6535f5a0> #<Tag:0x00007fef6535f2f8> #<Tag:0x00007fef6535f078>

Hello! I am writing a Python script to pull track and album-level discography data on specific artists to incorporate into a larger program. I am having issues with certain characters in strings pulled from MusicBrainz through the API though (’,", and - as far as I can tell). In the final export to csv, all are mangled into things like this - ‚Äô

I was running the script in Python 2, then redid it for Python 3 because I thought that would solve the problem, but it hasn’t.

I was wondering if anybody knows what I can do to get the characters mentioned above to appear properly in my export?

Try opening your stream with encoding of “utf-8”.

Thanks! I have tried encoding returns from the API to utf-8 at every step of the way, as well as encoding the csv exports in utf-8, but can’t seem to fix the issue. Is there a particular piece of code I should be putting in to open the stream in utf-8?

What program are you using to check the csv file that you created? I know for example that excel cannot easily open utf-8 csv files, you have to do something like this:

1 Like