Skip to content

Commit

Permalink
Added editing tool notebook
Browse files Browse the repository at this point in the history
The notebook `ipynb_to_docx.ipynb` is not part of this book per say, but instead is an editing tool to convert notebooks to Microsoft Word to then use Word and Grammarly to Edit
  • Loading branch information
GProtoZeroW authored Dec 16, 2020
1 parent 8b960f6 commit cddc850
Showing 1 changed file with 215 additions and 0 deletions.
215 changes: 215 additions & 0 deletions ipynb_to_docx.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is not part of the book, this is a editing tool that is used to create markdownfiles for the jupyter noteboks and then convert them to Microsoft Word in order to use Word and Grammerly to do editing "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[PosixPath('intro.ipynb'),\n",
" PosixPath('ipynb_to_docx.ipynb'),\n",
" PosixPath('AC_2/AC_1_Two-Three_Phase_AC.ipynb'),\n",
" PosixPath('AC_2/AC_2_RCL.ipynb'),\n",
" PosixPath('AC_2/AC_3_CoupledMag.ipynb'),\n",
" PosixPath('AC_2/AC_4_PZ.ipynb'),\n",
" PosixPath('AC_2/AC_5_twoports.ipynb'),\n",
" PosixPath('AC_2/AC_6_S_transmissionlines.ipynb'),\n",
" PosixPath('DC_1/DC_1.ipynb'),\n",
" PosixPath('DC_1/DC_1_op_ohm.ipynb'),\n",
" PosixPath('DC_1/DC_2_op_source_transform.ipynb'),\n",
" PosixPath('DC_1/DC_3_PracticalSourcs_sweeps_subcirucirts.ipynb'),\n",
" PosixPath('DC_1/DC_4_dependent_sources_and_tf.ipynb'),\n",
" PosixPath('DC_1/DC_5_Thvenin_Norton.ipynb'),\n",
" PosixPath('DC_1/DC_6_DC_MaxPower_MaxEfficiency.ipynb')]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"path=Path('.')\n",
"notebooks=[]\n",
"for p in path.rglob(\"*.ipynb\"):\n",
" if '_build' in str(p.absolute()):\n",
" continue\n",
" \n",
" elif 'ipynb_checkpoints' in str(p.absolute()):\n",
" continue\n",
" else:\n",
" notebooks.append(p)\n",
"notebooks"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"PosixPath('AC_2/AC_1_Two-Three_Phase_AC.ipynb')"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"notebooks[2].relative_to(notebooks[2].parent.parent)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"./intro.ipynb\n",
"[NbConvertApp] Converting notebook ./intro.ipynb to html\n",
"[NbConvertApp] Writing 288932 bytes to ./intro.html\n",
"./ipynb_to_docx.ipynb\n",
"[NbConvertApp] Converting notebook ./ipynb_to_docx.ipynb to html\n",
"[NbConvertApp] Writing 280069 bytes to ./ipynb_to_docx.html\n",
"./AC_2/AC_1_Two-Three_Phase_AC.ipynb\n",
"[NbConvertApp] Converting notebook ./AC_2/AC_1_Two-Three_Phase_AC.ipynb to html\n",
"[NbConvertApp] Writing 271926 bytes to ./AC_2/AC_1_Two-Three_Phase_AC.html\n",
"./AC_2/AC_2_RCL.ipynb\n",
"[NbConvertApp] Converting notebook ./AC_2/AC_2_RCL.ipynb to html\n",
"[NbConvertApp] Writing 271911 bytes to ./AC_2/AC_2_RCL.html\n",
"./AC_2/AC_3_CoupledMag.ipynb\n",
"[NbConvertApp] Converting notebook ./AC_2/AC_3_CoupledMag.ipynb to html\n",
"[NbConvertApp] Writing 271918 bytes to ./AC_2/AC_3_CoupledMag.html\n",
"./AC_2/AC_4_PZ.ipynb\n",
"[NbConvertApp] Converting notebook ./AC_2/AC_4_PZ.ipynb to html\n",
"[NbConvertApp] Writing 271910 bytes to ./AC_2/AC_4_PZ.html\n",
"./AC_2/AC_5_twoports.ipynb\n",
"[NbConvertApp] Converting notebook ./AC_2/AC_5_twoports.ipynb to html\n",
"[NbConvertApp] Writing 271916 bytes to ./AC_2/AC_5_twoports.html\n",
"./AC_2/AC_6_S_transmissionlines.ipynb\n",
"[NbConvertApp] Converting notebook ./AC_2/AC_6_S_transmissionlines.ipynb to html\n",
"[NbConvertApp] Writing 271927 bytes to ./AC_2/AC_6_S_transmissionlines.html\n",
"./DC_1/DC_1.ipynb\n",
"[NbConvertApp] Converting notebook ./DC_1/DC_1.ipynb to html\n",
"[NbConvertApp] Writing 271911 bytes to ./DC_1/DC_1.html\n",
"./DC_1/DC_1_op_ohm.ipynb\n",
"[NbConvertApp] Converting notebook ./DC_1/DC_1_op_ohm.ipynb to html\n",
"[NbConvertApp] Writing 319291 bytes to ./DC_1/DC_1_op_ohm.html\n",
"./DC_1/DC_2_op_source_transform.ipynb\n",
"[NbConvertApp] Converting notebook ./DC_1/DC_2_op_source_transform.ipynb to html\n",
"[NbConvertApp] Writing 362463 bytes to ./DC_1/DC_2_op_source_transform.html\n",
"./DC_1/DC_3_PracticalSourcs_sweeps_subcirucirts.ipynb\n",
"[NbConvertApp] Converting notebook ./DC_1/DC_3_PracticalSourcs_sweeps_subcirucirts.ipynb to html\n",
"[NbConvertApp] Writing 519428 bytes to ./DC_1/DC_3_PracticalSourcs_sweeps_subcirucirts.html\n",
"./DC_1/DC_4_dependent_sources_and_tf.ipynb\n",
"[NbConvertApp] Converting notebook ./DC_1/DC_4_dependent_sources_and_tf.ipynb to html\n",
"[NbConvertApp] Writing 555370 bytes to ./DC_1/DC_4_dependent_sources_and_tf.html\n",
"./DC_1/DC_5_Thvenin_Norton.ipynb\n",
"[NbConvertApp] Converting notebook ./DC_1/DC_5_Thvenin_Norton.ipynb to html\n",
"[NbConvertApp] Writing 587885 bytes to ./DC_1/DC_5_Thvenin_Norton.html\n",
"./DC_1/DC_6_DC_MaxPower_MaxEfficiency.ipynb\n",
"[NbConvertApp] Converting notebook ./DC_1/DC_6_DC_MaxPower_MaxEfficiency.ipynb to html\n",
"[NbConvertApp] Writing 444009 bytes to ./DC_1/DC_6_DC_MaxPower_MaxEfficiency.html\n"
]
}
],
"source": [
"for nb in notebooks:\n",
" #base=str(nb.absolute())\n",
" ipynb='./'+str(nb.relative_to(nb.parent.parent))\n",
" base=ipynb[:-6]\n",
" html=base+'.html'\n",
" docx=base+'.docx'\n",
" print(ipynb)\n",
" \n",
" !jupyter nbconvert --to html {ipynb}\n",
" !pandoc -s {html} -o {docx}\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autoclose": false,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit cddc850

Please sign in to comment.