Convert .json to ipynb - json

I am taking a course that uses ipython notebook. When I try to download the notebook (through File -> Download as -> ipython notebook), I get a file that ends with ".ipynb.json". It doesn't open as an ipython notebook but as a .json file so something like this:
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"_You are currently looking at **version 1.1** of this notebook. To download notebooks and datafiles, as well as get help on Jupyter notebooks in the Coursera platform, visit the [Jupyter Notebook FAQ](https://www.coursera.org/learn/python-data-analysis/resources/0dhYG) course resource._\n",
"\n",
"---"
]
},
...
}
I've tried deleting the ".json" in the file name and it doesn't work. How can I convert this file back to something that can be opened and run as an ipython notebook? Thank you very much!

My Solution: just remove the filename extension .json. for example, change myfile.ipynb.json to myfile.ipynb. Then, you can open it by a click in jupyter notebook !
I have encounter the same problem as you did. I found a link that describe what ipynb exactly is. see here http://ipython.org/ipython-doc/rel-1.0.0/interactive/nbconvert.html. It says ipynb file is actually json file. Hope this

On the Mac you could go and
Right click on the filename.ipynb.json
Click on Get Info from the list.
From the Get Info window, find the section Name&Extension remove the extension/suffix .json from the file name.
Hope that helps!

Are you trying download this from Github? Especially on Google Chrome browsers, I've had issues download .ipynb files using right click > Save link as... I'm not sure if other browsers have this issue (Microsoft Edge, Mozilla Firefox, Safari, etc.).
This causes issues since when downloading, it doesn't completely download the file usually and it becomes corrupted so you can't download an IPython notebook that may run properly. One trick when trying to download .ipynb files on Github is to click it, click Raw, then copy everything (Ctrl + A) and paste it into a blank file (using text editors such as Notepad, Notepad++, Vim, etc.) and save it as "whatever_file_name_you_choose.ipynb". Then you should be able to properly run this file, assuming a non-corrupted file was uploaded to Github.
A lot of people with very large, complicated IPython notebooks on Github will inevitably run into this issue when simply trying to download with Save link as.... Hopefully this helps!

I opened it as/with nbviewer and then selected it all and saved it as a "txt" file that I then opened in Notepad++. I then resaved it as a file with the extension ipynb and opened it in my jupyter notebook ok.

The easy thing to do is to copy the JSON contents into a notepad and save it again with .ipynb extension

Just remove the .json file extension leaving the .ipynb one, as pointed out by the following related post: https://superuser.com/questions/1497243/why-cant-i-save-a-jupyter-notebook-as-a-ipynb. As #jackie already said, you should consider them as .json files meant only to be edited by the IPython Notebook app itself, not for hand-editing.

Use a simple trick. Let that file get downloaded automatically. Re-download it again then it will prompt you to download and replace that file. At that time, you save that by replacing .json to .ipynb

After downloading the file with ipynb.json, Take the following steps:
Go your terminal/command line window
Navigate to the directory where your file is
Type:
windows OS: rename yourfile.ipynb.json to yourfile.ipynb
Unix/Linux: mv yourfile.ipynb.json to yourfile.ipynb
This work perfectly for me.

i tried this method and it worked. Just copy, paste it in notepad and save as "file_name.ipynb". hope this works for you too.

Related

Downloading/Opening .csv file using Google chrome, it changes extension of .csv file to .xls

I have an a tag in my html file that is pointed to a .csv file. Every time I click on the link it downloads the same file in .xls extension. Why?
I tried the following:
File download
<a href="./example.csv" download>File download</a>
File download
File download
I tried to open the file with the file:///myfolder/example.csv protocol but all of these had the same outcome.
Whereas in Firefox, IE, Edge this downloads the file in .csv extension.
How can I get chrome to download the .csv file in the .csv extension?
Locally on Windows 10 machine Google Chrome downloaded .csv file with .xls extension. But when I uploaded the same project to GitHub Pages, Google Chrome started downloading file with correct .csv extension.
So the solution is either in webserver settings or just to test outside of the local environment.
Have you tried supplying a value to the download attribute, like this?
File download
That may be enough to force the server to download the file as you expect. Also, try removing the "./" from the href attrbute of your a tag.
If you'd like to know more about the download attribute, check this link.
I didn't find any solution for it so I have made a work around:
if (fileType === 'text/csv') {
FileSaver.saveAs(newBlob, `${data}.csv`);
} else {
FileSaver.saveAs(newBlob, `${data}`);
}
This is working for me, if you find that browser makes the same issue for any other file and this file is not csv, try to implement it like this and it will also work.

How to use a download link to download a file in Python

Basically I am trying to write a script which will grab certain files on a webpage and download it to specific folders.
I am able to complete this with most of the webpages using Python, Selenium, and FirefoxPreferences.
However, when I try to grab off of this specific webpage, due to credential rights, I can't parse the html.
Here is the question. I am able to grab the download link for the file, and I can open a browser and have the open/save widget pop up. I can't however click or actually down the file any further. I have already set the Firefox Preferences to not show this widget, to download automatically, and to a specific file. This is ignored for some reason, and I am still left staring at the open browser, with the save/open widget.
How do I use the download link of a file to download to specific folder using Python... Selenium... any other related CS tricks. I don't want to build a bot to click the save for me. Too "hacky" and this is a company project.
Thanks!
you can try urllib
urllib.urlretrieve(<url>,<filename_with_path>)
import urllib
testfile = urllib.URLopener()
testfile.retrieve("http://randomsite.com/file.gz", "file.gz")
The good way to download a file with python.
Refer Here

Chrome Extension manifest.json difference

I'm trying to create zip package for my chrome extension for chome webstore, and having difficulties to determine what kind manifest.json format that requires in the zip package.
my first attempt was to copy the manifest.json that in my extension (compiled to .crx file) into the zip package, so the content of zip package
manifest.json
myextension.crx
but this approach leads to a problem where background script cannot be loaded when try to install the extension in chrome.
my second attempt was to strip the manifest json and only leave some fields such name, description, and icon. It seems my second attempt was successful, as my extension can be installed.
Is my approach was correct? please advise.
The correct format of the manifest file is documented here. That having said, I suspect that the issue has nothing to do with your manifest file, but the structure of your zip file. When submitting a zip file, make sure that you zip the directory's content, not the directory itself.
E.g. the following structure is OK:
manifest.json
background.js
...
The following is not OK:
extension/manifest.json
extension/background.js
You've probably created the following situation, which is not OK, because it declares the background script as "background.js", while it's actually located at "extension/background.js":
manifest.js containing "background": {"scripts": ["background.js"] }
extension/background.js
Your second attempt probably worked because you had zipped the file in the correct way.
Actually you should upload a ZIP archive that contains just the root directory of your extension (nothing should be CRXed). According to the "Get Started" guide:
Create a ZIP archive of the directory that contains manifest.json and the icon. On Windows, you can do this by right-clicking myapp and choosing the menu item Send to > Compressed (zipped) folder. On Mac OS X, control-click myapp and choose Compress "myapp".
If you like to use the command line, you might enter this:
zip -r myapp.zip myapp
Note: The ZIP archive should not contain just the contents of the extension's root directory, but the root directory itself (with all its content, of course).
(BTW, I have no idea why your second attempt worked - according to the docs it shouldn't.)
UPDATE:
After trying it out myself, both approaches seem to work.
Bottom line, upload a ZIP archive with the content of your extension and not any CRXed stuff. Google will produce the CRX itself.

Unable to save a file as JSON?

Am in the need of creating a file with a extension of JSON(Json file). But I'm unable to create. When I try save a file with json extension like file name followed by a .JSON it is takes as,
filename.JSON.txt
How to solve this?? Am using windows 7(32 bit) OS. Please suggest something ???
When you Save As..., make sure the "Save as type" dropdown contains "All Files" and not "Text Documents(*.txt)". That way it won't add the extension '.txt' but the extension you add.
You have to delate the extension .txt to get a JSON file.
I also struggled with this, but in the end it was quite simple...
In the TextEdit menu, go to "Format" and choose "Make Plain Text".
Then, save the file and write the filename with the .json extension. Pop-up dialogue will ask if you want to save with .json or .txt, just choose .json to confirm!

CHM file unreadble if saved to hdd

I've just downloaded JSon.Net for framework 4.0 as a zip file.
Opening zip (using WinRar) I'm able to open Documentation.chm file by double-clicking over the name listed and the help file is well done.
Anyway if I extract this file to hdd and I open it, help is unreadable.
Sounds silly, but it's happening.
Thanks for your help!!!
EDITED:
Another tip: unreadble chm file is located in D:\.... (second NTFS partition of first hdd); if I save it on my desktop, chm file becomes readable !!! Crazy...
------------------------------------
---------- SOLUTION ----------
------------------------------------
I answer my question to close it and to help someone who finds in my same trouble.
Using tip suggested by #Marco van de Voort I searched Google for "chm unblock" and found this link:
Your CHM files are stored in the folder with '#' (hash) character in
the path Many C# developers discovered that their documentation
and e-books in CHM format cannot be read because they were storing
their CHM files in the directories like 'C:\E-books\C#\'. The hash
character signifies an anchor in HTML so the CHM viewer fails to
resolve the path properly and to retrieve the content.
That was my problem: I had path with a #... and I'd never thought this could be a great mess for CHM files!!!
Thanks to SO mates for the help given !!
Windows keeps track of downloaded files on NTFS systems, and puts certain restrictions on them. If you extract with windows explorer, this status propagates from archive to file. Using a third party tool (winrar in your case, I use INFO zip) can circumvent this.
Some descriptions and other links can be found
http://wiki.lazarus.freepascal.org/chm_backend_for_fpdoc#Troubleshooting
Free Pascal (2.4.4) has some tool to unlock them. (chmls unblock). It is done by truncating an alternate filestream (therefore it only works with NTFS). I found this info somewhere on stackoverflow, but can't quickly find the link.
It might be that virtual folders like desktop don't fully support this.
maybe the references to some content is to web or no chm file. maybe if you can disassamble in CHM editor and change paths can fix it.
maybe this can help you
There are security permissions applied to this file type by a recent patch.
you need to unblock the file:
http://www.helpscribble.com/chmnetwork.html
instead of thinking many possibilities of "windows security permission", get a CHM reader or wrap your CHM using winrar, and doubleclick to view it like you did.
It's save your time a lot!!
So, two simple solutions are:
have a CHM reader: https://blog.kowalczyk.info/articles/chm-reader-viewer-for-windows.html
OR right click CHM file/s, > Add to RAR Archive.
If you want to read it, double click RAR file > double click CHM file. BINGO!!