Error! C:\File\Example.Db Is Not Utf-8 Encoded Ipython Notebook

Error! blahfile is not UTF-8 encoded. Saving disabled

The very simple answer to this is none of the above. This is a very misleading error message, especially when the code you've written was designed to save a binary file with a weird extension.

What this actually means is ...

    I HAVE NO IDEA HOW TO DISPLAY THIS DATA ! - Yours Jupyter

So, go to your File Explorer, Finder navigate to the just saved file and open it. Voila !!
Everything worked exactly as planned, there is no error.

Hope this saves other people many hours of debugging, and please Jupyter, change your error message.

How to avoid problem with encode UTF-8 error

There is nothing wrong with the program itself. You are getting this error because you are trying to read a file which is not encoded as UTF-8 as UTF-8-encoded. You have to either convert the contents of the file to UTF-8 or specify a different encoding (the one that the file actually uses) in the call to open.

Unreadable Notebook NotJSONError('Notebook does not appear to be JSON: u\'{\\n "cells": [\\n {\\n "cell_type": "...',)

I just had the same issue after upgrading from IPython 0.13 (ish) to Jupyter 4.

The problem in my case were a few rogue trailing commas in the JSON, for example the comma following "outputs" in:

...
"language": "python",
"metadata": {},
"outputs": [],
},

After removing the commas, Jupyter/IPython could again read the notebook (and upgraded it to version 4). I hope this helps.

UnicodeDecodeError when reading CSV file in Pandas with Python

read_csv takes an encoding option to deal with files in different formats. I mostly use read_csv('file', encoding = "ISO-8859-1"), or alternatively encoding = "utf-8" for reading, and generally utf-8 for to_csv.

You can also use one of several alias options like 'latin' or 'cp1252' (Windows) instead of 'ISO-8859-1' (see python docs, also for numerous other encodings you may encounter).

See relevant Pandas documentation,
python docs examples on csv files, and plenty of related questions here on SO. A good background resource is What every developer should know about unicode and character sets.

To detect the encoding (assuming the file contains non-ascii characters), you can use enca (see man page) or file -i (linux) or file -I (osx) (see man page).

os.getcwd() leading to FileNotFoundError

Use os.path.join instead of specific concatenation

Use shutil to move (instead of MV)

Use os.mkdir to make directory

Specify FileExistsError in error handling on mkdir



Related Topics



Leave a reply



Submit