Skip to content

Commit

Permalink
Enhance Google Colab Notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
AliOsm committed Jul 26, 2024
1 parent e67d84d commit 7f69595
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions colab_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"!pip install -U tahweel==0.0.11 > tahweel_logs.txt\n",
"\n",
"# Setup poppler-utils.\n",
"!apt-get install poppler-utils > apt_logs.txt\n",
"!apt-get update > apt_update_logs.txt\n",
"!apt-get install poppler-utils > apt_install_logs.txt\n",
"\n",
"# Get inputs.\n",
"\n",
Expand All @@ -63,6 +64,8 @@
"# Imports.\n",
"import os\n",
"\n",
"from pathlib import Path\n",
"\n",
"from google.colab.auth import authenticate_user\n",
"from google.colab.files import upload, download\n",
"\n",
Expand All @@ -72,11 +75,11 @@
"\n",
"print('حدد الملف أو الملفات التي تريد تحويلها:')\n",
"\n",
"file_names = list(upload().keys())\n",
"file_names = list(map(Path, upload().keys()))\n",
"\n",
"print('جارٍ تحويل الملفات.')\n",
"\n",
"file_names_argument = ' '.join([f'\"./{file_name}\"' for file_name in file_names])\n",
"file_names_argument = ' '.join([f'\"./{str(file_name)}\"' for file_name in file_names])\n",
"\n",
"if docx_remove_newlines == 'نعم':\n",
" docx_remove_newlines = '--docx-remove-newlines'\n",
Expand All @@ -88,9 +91,9 @@
"print('جارٍ تنزيل المخرجات.')\n",
"\n",
"for file_name in file_names:\n",
" if file_name.endswith('.pdf'):\n",
" download(file_name.replace('.pdf', '.docx'))\n",
" download(file_name.replace('.pdf', '.txt'))"
" if file_name.suffix == '.pdf':\n",
" download(file_name.with_suffix('.docx'))\n",
" download(file_name.with_suffix('.txt'))\n"
]
},
{
Expand Down

0 comments on commit 7f69595

Please sign in to comment.