Skip to content

Commit

Permalink
Merge pull request #4 from Tranquility2/tqdm
Browse files Browse the repository at this point in the history
- Using Tqdm
- Updates to requirements
  • Loading branch information
Tranquility2 authored Apr 7, 2024
2 parents 7c97431 + 1ef9ecf commit e69cd47
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 19 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ run:
python3 xls_updater/app.py

setup:
python3 -m pip install .
python3 -m pip install --editable '.[dev,test]'

setup-dev:
python3 -m pip install --editable '.[dev]'
Expand Down Expand Up @@ -49,7 +49,6 @@ check-mypy:

compile:
python3 -m pip install --upgrade pip-tools
python3 -m piptools compile -o requirements.txt pyproject.toml
python3 -m piptools compile -o requirements-dev.txt --extra dev pyproject.toml
python3 -m piptools compile -o requirements-test.txt --extra test pyproject.toml

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies = [
"click==8.1.7",
"openpyxl==3.1.2",
"xlrd==2.0.1",
"alive_progress==3.1.5"
"tqdm==4.66.2"
]
[project.optional-dependencies]
dev = [
Expand Down
4 changes: 1 addition & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
about-time==4.2.1 # via alive-progress
alive-progress==3.1.5 # via xls-updater (pyproject.toml)
astroid==3.0.1 # via pylint
black==23.10.1 # via xls-updater (pyproject.toml)
cfgv==3.4.0 # via pre-commit
Expand All @@ -8,7 +6,6 @@ dill==0.3.7 # via pylint
distlib==0.3.7 # via virtualenv
et-xmlfile==1.1.0 # via openpyxl
filelock==3.12.4 # via virtualenv
grapheme==0.6.0 # via alive-progress
identify==2.5.30 # via pre-commit
isort==5.12.0 # via pylint, xls-updater (pyproject.toml)
mccabe==0.7.0 # via pylint
Expand All @@ -24,6 +21,7 @@ pylint==3.0.2 # via xls-updater (pyproject.toml)
pyyaml==6.0.1 # via pre-commit
tomli==2.0.1 # via black, mypy, pylint
tomlkit==0.12.1 # via pylint
tqdm==4.66.2 # via xls-updater (pyproject.toml)
typing-extensions==4.9.0 # via astroid, black, mypy
virtualenv==20.24.6 # via pre-commit
xlrd==2.0.1 # via xls-updater (pyproject.toml)
Expand Down
4 changes: 1 addition & 3 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
about-time==4.2.1 # via alive-progress
alive-progress==3.1.5 # via xls-updater (pyproject.toml)
click==8.1.7 # via xls-updater (pyproject.toml)
coverage==7.4.4 # via pytest-cov
et-xmlfile==1.1.0 # via openpyxl
exceptiongroup==1.2.0 # via pytest
grapheme==0.6.0 # via alive-progress
humanize==4.9.0 # via xls-updater (pyproject.toml)
iniconfig==2.0.0 # via pytest
numpy==1.26.4 # via pandas, pyarrow
Expand All @@ -20,6 +17,7 @@ python-dateutil==2.9.0.post0 # via pandas
pytz==2024.1 # via pandas
six==1.16.0 # via python-dateutil
tomli==2.0.1 # via coverage, pytest
tqdm==4.66.2 # via xls-updater (pyproject.toml)
tzdata==2024.1 # via pandas
xlrd==2.0.1 # via xls-updater (pyproject.toml)
xlwt==1.3.0 # via xls-updater (pyproject.toml)
7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

6 changes: 3 additions & 3 deletions xls_updater/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pathlib

import xlrd
from alive_progress import alive_bar
from openpyxl.workbook import Workbook
from tqdm import tqdm


def convert_xls_to_xlsx(src_file_path: pathlib.Path) -> None:
Expand All @@ -20,7 +20,7 @@ def convert_xls_to_xlsx(src_file_path: pathlib.Path) -> None:
sheet_xls = book_xls.sheet_by_name(sheet_name)
total_cells += sheet_xls.nrows * sheet_xls.ncols

with alive_bar(total_cells, title="Converting xls to xlsx", monitor=False, stats="{eta}") as progress_bar:
with tqdm(total=total_cells, desc="Converting xls to xlsx") as progress_bar:
for sheet_index, sheet_name in enumerate(sheet_names):
sheet_xls = book_xls.sheet_by_name(sheet_name)
if sheet_index == 0:
Expand All @@ -32,6 +32,6 @@ def convert_xls_to_xlsx(src_file_path: pathlib.Path) -> None:
for row in range(0, sheet_xls.nrows):
for col in range(0, sheet_xls.ncols):
sheet_xlsx.cell(row=row + 1, column=col + 1).value = sheet_xls.cell_value(row, col)
progress_bar() # pylint: disable=not-callable
progress_bar.update(1)

book_xlsx.save(dst_file_path)

0 comments on commit e69cd47

Please sign in to comment.