Skip to content

Commit

Permalink
rolling back to other dbs, keeping sinan
Browse files Browse the repository at this point in the history
  • Loading branch information
luabida committed Mar 24, 2023
1 parent 324ba1d commit 5cadf11
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pysus/online_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def parquets_to_dataframe(
at time.
"""

parquets = Path(parquet_dir).glob("*.parquet")
parquets = list(Path(parquet_dir).glob("*.parquet"))

try:
chunks_list = [
Expand Down Expand Up @@ -157,7 +157,7 @@ class FTP_Inspect:

database: str
_ds_paths: list
ftp_server: FTP = FTP_datasus()
ftp_server: FTP = FTP("ftp.datasus.gov.br")
available_dbs: list = list(DB_PATHS.keys())

def __init__(self, database: str) -> None:
Expand Down Expand Up @@ -187,7 +187,7 @@ def last_update_df(self) -> pd.DataFrame: # Legacy
)
return pd.DataFrame()

with FTP_datasus() as ftp:
with self.ftp_server.login() as ftp:
response = {
"folder": [],
"date": [],
Expand Down Expand Up @@ -312,9 +312,10 @@ def list_all(
chunks, to preserve memory, that are read using pandas and pyarrow.
"""
available_dbs = list()
ftp = FTP("ftp.datasus.gov.br")
ftp.login()
for path in self._ds_paths:
try:
ftp = FTP_datasus()
# CNES
if self.database == "CNES":
if not CNES_group:
Expand Down Expand Up @@ -538,7 +539,8 @@ def _extract_dbc(self, DBC_path: str, local_dir: str = cache_dir) -> str:
if Path(filepath).exists():
return str(filepath)
try:
ftp = FTP_datasus()
ftp = ftp = FTP("ftp.datasus.gov.br")
ftp.login()
ftp.cwd(filedir)
ftp.retrbinary(
f"RETR {filename}",
Expand Down

0 comments on commit 5cadf11

Please sign in to comment.