Convert Jupyter notebook into MS word document .doc?
Asked Answered
T

6

16

In Jupyter Notebook, I am able to convert a notebook to pdf and HTML using nbconvert. However, there is no way to convert it into .doc(Word Document). Is there a way to convert it to MS Word keeping the same text highlights and table structure?

Tolmann answered 8/11, 2018 at 12:26 Comment(1)
There is a export word extension on githubShepp
M
8

To convert the Jupyter Notebook to Word

  1. Go to File and download as markdown(.md)
  2. Go to https://cloudconvert.com/md-to-docx and download as doc file
Morphia answered 28/5, 2019 at 2:21 Comment(2)
That method did not help in sustaining the tables it actually destroyed the shape. Is there possibly a different way of doing it?Catenate
any option that would not rely on an external website ? (not very happy to provide data to someone external. The site is even blocked at my current job).Abbott
G
19

The simplest way to convert a jupyter notebook (.ipynb file) to word file (.docx) is using pandoc. First install pandoc, follow instruction here. Once installed, open your terminal to check if its installed correctly by using

pandoc --version

Once you are sure its installed there, use the following line of code in the terminal to convert the jupyter notebook to word file.

pandoc jupyter_file.ipynb -s -o new_word_file.docx

One word of caution, you first need to get into the directory in which your jupyter notebook is, in your command prompt. You can do that by typing the path after writing cd(change directory) in the command prompt. This code will create the word file in the same folder where the Jupyter notebook is.

Screeshot of terminal code

Grosmark answered 15/5, 2021 at 11:20 Comment(1)
do you have some sample output? Doesn't look at all pretty to me :\Groveman
M
8

To convert the Jupyter Notebook to Word

  1. Go to File and download as markdown(.md)
  2. Go to https://cloudconvert.com/md-to-docx and download as doc file
Morphia answered 28/5, 2019 at 2:21 Comment(2)
That method did not help in sustaining the tables it actually destroyed the shape. Is there possibly a different way of doing it?Catenate
any option that would not rely on an external website ? (not very happy to provide data to someone external. The site is even blocked at my current job).Abbott
U
7

Use this website https://alldocs.app/convert-jupyter-notebook-to-word-docx

Upload the .ipynb, it works with code, text and pictures

Unitary answered 11/9, 2021 at 19:7 Comment(1)
Do they have an API?California
C
6

To get the best result, it needs multi-steps but will get a nice shape as you wish

  1. Download the notebook as a latex file

  2. Then upload this file into overleaf https://www.overleaf.com/project and customize it by splitting the pages as you please. \newpage

  3. Download the pdf file from Overleaf into your local computer.

  4. Convert the downloaded pdf into Docx using either of the following

    1. Open adobe acrobat and press on "File" then "Extract to" then " MS word" then "Word document"
    2. use the following link https://pdf2docx.com/

The outcome was awesome! enter image description here

Catenate answered 20/2, 2021 at 15:32 Comment(1)
best solution .. works with overleaf too for those in need :). However i am having trouble including the .tex in a book i am writing in overleaf. Any ideas why ? I can preview the file alone, but when i include it, it fails and prints whateverSilber
H
1
  1. Use the command "jupyter notebook filename.ipynb" to run the notebook in a browser.
  2. Use the notebook's File menu to Download as HTML.
  3. Open MS Word, and, from Word, open the HTML file.

This gives a copy of the notebook that is more faithful to the original notebook than, for example, going via markdown and pandoc, which does not render the notebook perfectly.

You can then carry out any Word operation you like (eg. save as docx, indicate changes using Track Mode TRK, etc, etc).

I have not tried tables. Could someone try using tables with this technique and give feedback?

Housewifely answered 23/11, 2021 at 16:37 Comment(0)
H
1

For me, vertopal worked great doing the following steps:

  1. Upload your ".ipynb" file in the website.
  2. Set the converter from "ipynb to docx".
  3. Click "Convert".
  4. Download your converted ".docx" file.
Hungary answered 8/1 at 23:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.