Skip to content

Commit

Permalink
Merge pull request #127 from fga-eps-mds/igorpenhaa-patch-1
Browse files Browse the repository at this point in the history
fix: backing first version
  • Loading branch information
igorpenhaa authored Dec 5, 2023
2 parents d3460d7 + f062e8c commit 8f8fd9e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/ez_docs/modules/data_cleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ def find_delimiter(location: str) -> str:
delimiters_dict = sorted(delimiters_dict.items(), key=lambda item: item[1])
return delimiters_dict[0][0]

# Returns a pandas DataFrame according to an extension
def filter_format(location: str) -> pd.DataFrame:
extension = location.split(".")[-1]
if extension == "csv":
return pd.read_csv(location, delimiter=find_delimiter(location))
elif extension == "html":
return pd.read_html(location)
elif extension == "json":
return pd.read_json(location)
elif extension == "xlsx":
return pd.read_excel(location)
elif extension == "xml":
return pd.read_xml(location)
else:
raise Exception(
f"""
\033[0;31mThe extension '{extension}' is not accepted.\n
Valid: csv, html, json, xlsx, xml.\033[0m
"""
)

# Converts the data_set to the format specified in the architecture
def filter_data(location: str, constraint: str = "") -> list:
Expand Down

0 comments on commit 8f8fd9e

Please sign in to comment.