Formatting results from Google Search Console API

Issue: using python, google search console API csv lines starts all with the following string

 b'\xef\xbb\xbf2019-04-20'

Solution:

The \xef\xbb\xbf is the BOM. It came here because I was actually encoding the result in utf-8-sig instead of utf-8. Just make sure to properly encode the returned strings in utf-8 and this won’t bother you.

So after this correction we are left with the following:

 b'2019-04-20'

This indicates that the date (which is the key) is actually of type bytes and not of type string.

To solve this just make sure to decode the bytes to string with the following code:

key.decode('utf-8')