From e794242a031e8794971b41a1e133ab22ef77fd8f Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Mon, 7 Oct 2024 05:27:46 +0200 Subject: [PATCH] Feat: test on pandas xlsx and ods file reader --- dashboard/libs/repository/fs_repository.py | 35 +++++++++++----- requirements.txt | 9 ++--- .../username-password-recovery-code.xls | Bin 0 -> 6656 bytes .../username-password-recovery-code.xlsx | Bin 6118 -> 6477 bytes tests/repository/fs_examples/username.csv | 2 +- tests/repository/test_fs_repository.py | 38 ++++++++++++++++++ 6 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 tests/repository/fs_examples/username-password-recovery-code.xls diff --git a/dashboard/libs/repository/fs_repository.py b/dashboard/libs/repository/fs_repository.py index 2d9d78c..95e56a3 100644 --- a/dashboard/libs/repository/fs_repository.py +++ b/dashboard/libs/repository/fs_repository.py @@ -4,6 +4,10 @@ import pandas as pd from .repository import AbstractRepository +ACCEPTABLE_EXTENTIONS = { + "csv": [".csv"], + "excel": [".xls", ".xlsx"], +} class FSRepository(AbstractRepository): def __init__(self, name, basepath, metadata_engine=None): @@ -20,18 +24,30 @@ class FSRepository(AbstractRepository): if only_files: return [ - str(f.relative_to(dirpath)) for f in dirpath.iterdir() if not f.is_dir() + str(f.relative_to(dirpath)) + for f in dirpath.iterdir() + if not f.is_dir() and not str(f).startswith(".") ] if only_directories: if recursive: - return [str(f[0].relative_to(dirpath)) for f in dirpath.walk()] + return [ + str(f[0].relative_to(dirpath)) + for f in dirpath.walk() + if not str(f).startswith(".") + ] return [ - str(f.relative_to(dirpath)) for f in dirpath.iterdir() if f.is_dir() + str(f.relative_to(dirpath)) + for f in dirpath.iterdir() + if f.is_dir() and not str(f).startswith(".") ] - return [str(f.relative_to(dirpath)) for f in dirpath.iterdir()] + return [ + str(f.relative_to(dirpath)) + for f in dirpath.iterdir() + if not str(f).startswith(".") + ] def schemas(self, recursive=True) -> list[str]: return self.ls("", only_directories=True, recursive=True) @@ -49,16 +65,17 @@ class FSRepository(AbstractRepository): table_path = self.build_table_path(table, schema) pass - def read(self, table: str, schema: str = ".", read_options={}): + def read(self, table: str, schema: str = ".", **read_options): table_path = self.build_table_path(table, schema) + assert table_path.exists() extension = table_path.suffix - if extension == ".csv": + if extension in ACCEPTABLE_EXTENTIONS["csv"]: return pd.read_csv(table_path, **read_options) - if extension == ".xlsx": - return pd.read_excel(table_path, **read_options) + if extension in ACCEPTABLE_EXTENTIONS["excel"]: + return pd.read_excel(table_path, engine = "openpyxl", **read_options) - raise ValueError("Can't open the table") + raise ValueError("Bad extention. Can't open the table.") def write(self, content, table: str, schema: str = "."): table_path = self.build_table_path(table, schema) diff --git a/requirements.txt b/requirements.txt index dd51a46..93d88e7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ jupyter==1.0.0 -pandas==1.5.0 -pdf-oralia==0.3.11 -pydantic==2.6.1 +pandas==2.2.2 +pydantic==2.8.2 click==8.1.7 -dlt[duckdb]>=0.4.3a0 -openpyxl>=3.0.0 +openpyxl==3.1.5 +xlrd==2.0.1 diff --git a/tests/repository/fs_examples/username-password-recovery-code.xls b/tests/repository/fs_examples/username-password-recovery-code.xls new file mode 100644 index 0000000000000000000000000000000000000000..af0329b4cbfb66ffdcea1454a2de462bab523e18 GIT binary patch literal 6656 zcmeHLYiL|W6h3z!>88)5c70oKQ=6u3Qg@Ry4@8^3ZAooN>jM$>W^P5TSoW@qwT}6l@X1ABrLf>aXfQQDhZG1l#rd&fM*;+r%bT1f{c_d*_@v zGvAprXJ*dcPd{ls@!}hoel2z78i~rOa-%fV$Su_8SNJB82N`M+cY+De%|3gzdZ|W>OFf2ZPMX_a@cz6eL2rE7Nav>t77G^d* zYtM_>=$}pJJbu*!XY&=?YyHpjo9B2GG}Hd)na};d5VQ!i7_ z3qcowE(To!x)gL7=yK2%pyi+|K{jXws0FkVbQNe7s1>vt)CO7uS_@hSY6o?I)`K{Q zRQP7S3-#`h@4>q_tXDmAzBZi)8WUK>hPb@5=p!EadiH;fh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0zS`ZU#(xi9|~&@Jl3CYEyY*$?PI9H6cK+wuoy`P( z!5=Hy+wRS{IlI5NW1lnP=5nrXsm5q zw>|rtUVbVe>sG({C0FP^5FO5T8qWPa0HPNMLAVp;77%yyD2V%b5=0}vJ!$@XvYrMF zfMomo3@TG+1!X{==E3?@`_@Nx{O}ba&nPq5PmIXtAAkP*`pcT0c@Fls|Mu!u$l`Uf z+aTkv<=`Yn9sAPOA-s74u-G8BbIxoZ0Fh^%bKW#Ld6OFykn>dgb3ZcX(i_&NP*6Lw z{FC2*)c(2{JQFdTlexC!W_*1LeP16ic=M zIgc3G0~;oca1Kx6bB(zFSZ34pYAEdt6)oWA#GOsIX?1uD8D#UER;f(zkWm|4{Q@~Rd;0#y a{5RC#hi079Yp(vU{r+}Nz+vZe!T$p~UWWky literal 0 HcmV?d00001 diff --git a/tests/repository/fs_examples/username-password-recovery-code.xlsx b/tests/repository/fs_examples/username-password-recovery-code.xlsx index 1723d5cbfa17b25205e4dc51a9fdbdd51688bacf..1e2d2dd6e8c5122c14b6e6cc8aecfd6faa09b759 100644 GIT binary patch delta 4904 zcmaJ_1yEFP*Waaf>0Y|K7g$OpC8ZJg6H?L*(z$d?Ex8CtC?Wz93oIc>2?9z8NFya8 zol3|D&ilPDzVprZ+_`t=-uXRe&iS3+bIzQ*E;KAcpsRt2MF9YV!2q;+=oK2x}HJ%_UGS|GbE`OqRO+7#K#qmPv`G>yOimng^t3y0z zcTfvZIbA;=$%eM4`qBpwa>Wiu5yVB3Eh08%U34_mc$p=Pv>fq1pN7?5J8IBveS18jEl{n2_=JFg0 zF(-}dsz9*mwojJEMoKWC3yv*y&=HLMxswNU?gFTXKXD#wDYpD9W1Pa|Sfo-Kzy*K* zsArt6o|qT&EF3MQQf-i`6#IEhB#W+r8;6~2u+F&D+F;jQO*29k1x#V;c-_6OWP|5Wlad_YS4nf*c&S- zFa`h+hY0}OR!Myrra8uqOy;p!;N~9rP>RsSnl~436~|z1T+cS|*v$+YR8_#7W}@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%IPo6|4b;x2{GTwwXgj%eJeH{@-<D0Ka@4Bd0rm1%?C@E&?( z`_iEgfHc^r-<0X&3V-IjFD&iLG**3bwtnYII+Qjo5+y{W9}}|F^Lq?`eH2P+06PJ; z5*Qz)&zR!$Cg51)bN6;Yxbb*7I{eGS-wuf2 zx04a|KTM-emXOA+Q!)M3=Qd~EaQ44tKaPVM@)xh)-j3G?j9Y?x zty(!->bN?)xWO!)T@n9lsvJT8hAhb~V>C2pvRmfnE-wFVtx5#H9cS`?nCD%qPvxDR g+!0RhrjNZ{5N^i*8UgFhO+UQr7I4ELlsDS{0innb;{X5v diff --git a/tests/repository/fs_examples/username.csv b/tests/repository/fs_examples/username.csv index 006ac8e..45d43d4 100644 --- a/tests/repository/fs_examples/username.csv +++ b/tests/repository/fs_examples/username.csv @@ -1,4 +1,4 @@ -Username; Identifier;First name;Last name +Username;Identifier;First name;Last name booker12;9012;Rachel;Booker grey07;2070;Laura;Grey johnson81;4081;Craig;Johnson diff --git a/tests/repository/test_fs_repository.py b/tests/repository/test_fs_repository.py index c005fed..b6617dd 100644 --- a/tests/repository/test_fs_repository.py +++ b/tests/repository/test_fs_repository.py @@ -2,6 +2,7 @@ import shutil from pathlib import Path import pytest +from pandas import pandas from dashboard.libs.repository.fs_repository import FSRepository @@ -42,5 +43,42 @@ def test_init(location): assert repo.tables("username") == [ "username.csv", "username-password-recovery-code.xlsx", + "username-password-recovery-code.xls", ] assert repo.tables("salary") == ["salary.pdf"] + + +def test_read_csv(location): + repo = FSRepository("example", location) + username = repo.read("username.csv", "username", delimiter=";") + assert list(username.columns) == [ + "Username", + "Identifier", + "First name", + "Last name", + ] + assert len(username.index) == 5 + + +def test_fake_read_xlsx(location): + repo = FSRepository("example", location) + df = pandas.read_excel( + location / "username" / "username-password-recovery-code.xls" + ) + print(df) + + +def test_read_xlsx(location): + repo = FSRepository("example", location) + username = repo.read("username-password-recovery-code.xls", "username") + assert list(username.columns) == [ + "Username", + "Identifier", + "One-time password", + "Recovery code", + "First name", + "Last name", + "Department", + "Location", + ] + assert len(username.index) == 5