babilonia.tools.core#
Core constants and functions for the babilonia.tools package.
Functions
|
Reads multiple CSV files and concatenates them into a single DataFrame. |
|
Extracts the account identifier from a formatted data type string. |
Parses command-line arguments for the Babilonia utilities. |
|
|
Extracts the bank name from a formatted data type string. |
|
|
|
Constructs a glob-style file path pattern for bank statement CSV files. |
|
Displays a preview of a DataFrame with a specified maximum number of rows. |
- babilonia.tools.core.preview_df(df, row_max=20)[source]#
Displays a preview of a DataFrame with a specified maximum number of rows.
- Parameters:
df (
pandas.DataFrame) – The dataset to be displayedrow_max (int) – The maximum number of rows to show in the console. Default value =
20
- Returns:
None
- Return type:
None
- babilonia.tools.core.concat_dfs(ls_files)[source]#
Reads multiple CSV files and concatenates them into a single DataFrame.
- Parameters:
ls_files (list) – A list of file paths to be read
- Returns:
A unified DataFrame containing data from all provided files
- Return type:
pandas.DataFrame
Note
This function reads each file using
;as a separator and forces all columns tostrtype to avoid type inference issues during concatenation. The resulting index is reset and the old index is dropped.
- babilonia.tools.core.get_bank(data_type)[source]#
Extracts the bank name from a formatted data type string.
- Parameters:
data_type (str) – The string containing bank and account info separated by a hyphen
- Returns:
The extracted bank name
- Return type:
str
- babilonia.tools.core.get_account(data_type)[source]#
Extracts the account identifier from a formatted data type string.
- Parameters:
data_type (str) – The string containing bank and account info separated by a hyphen
- Returns:
The extracted account identifier
- Return type:
str
- babilonia.tools.core.get_file_pattern_statement_t0(data_type, folder, year=None)[source]#
Constructs a glob-style file path pattern for bank statement CSV files.
- Parameters:
data_type (str) – The string containing bank and account info separated by a hyphen
folder (str) – The base directory path where files are located
year (int) – [optional] The specific year to filter files. Default value =
None
- Returns:
A formatted raw string representing the file search pattern
- Return type:
str
Note
If
yearis not provided, the function uses a wildcard*to match all available year directories. The resulting pattern follows the naming convention:EXTRATO_{BANK}_{ACCOUNT}_*_T0.csv.
- babilonia.tools.core.get_arguments()[source]#
Parses command-line arguments for the Babilonia utilities.
- Returns:
An object containing the parsed arguments:
folder,type, andyear- Return type:
argparse.Namespace
The function handles the following arguments: *
-f/--folder: Path to the target processing directory. *-t/--type: The specific account type string. *-y/--year: The integer year to filter processing (defaults toNone).