babilonia.tools.core#

Core constants and functions for the babilonia.tools package.

Functions

concat_dfs(ls_files)

Reads multiple CSV files and concatenates them into a single DataFrame.

get_account(data_type)

Extracts the account identifier from a formatted data type string.

get_arguments()

Parses command-line arguments for the Babilonia utilities.

get_bank(data_type)

Extracts the bank name from a formatted data type string.

get_file_pattern_cashflow_daily(data_type, ...)

get_file_pattern_statement_t0(data_type, folder)

Constructs a glob-style file path pattern for bank statement CSV files.

preview_df(df[, row_max])

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 displayed

  • row_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 to str type 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 year is 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_file_pattern_cashflow_daily(data_type, folder, year=None)[source]#
babilonia.tools.core.get_arguments()[source]#

Parses command-line arguments for the Babilonia utilities.

Returns:

An object containing the parsed arguments: folder, type, and year

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 to None).