pythonjupyter-notebook

Convert Jupyter notebook file from plain text to python


I created yesterday a Jupyter notebook file in Python 3 and saved it. I do not know what bad manipulation I did but today, when I want to reopen this file, I realize that it is in plain text format! Is there a way to revert to a python encoded format?

The file doesn't have extension ipynb (It has no extension) ; it looks like this (few first lines):

 "cells": [
  {
   "cell_type": "code",
   "execution_count": 377,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\thaly\\anaconda3\\lib\\site-packages\\pandas\\core\\indexing.py:965: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  self.obj[item] = s\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",````


Solution

  • The file you have saved is a Jupyter notebook (internally it is a JSON file).

    To convert this notebook, you can: