Skip to main content

Style Status Docs Status Tests Status Top Language Status Code Style Documentation PyPI Latest Release PyPI Downloads


babilonia

Handle accounting and finances in Brazil using Python.


Install

python -m pip install babilonia

Quick Gallery

API

Parse bank statement CSV

Convert raw bank exports to a canonical pandas.DataFrame.

Input (extrato_poupanca.csv from Banco do Brasil):

"Data","Histórico","Valor",
"01/08/2025","Juros","3,83 C",
"01/08/2025","Reajuste Monetário - BACEN","16,67 C",
"11/08/2025","Transferência de Crédito","1.000,00 C",
from babilonia.accounting import CashFlowBBPP

cf = CashFlowBBPP()
cf.load_data("./extrato_poupanca.csv")
cf.standardize()
print(cf.data)
        Data    Valor                   Categoria Descricao
  2025-08-01     3.83                       Juros
  2025-08-01    16.67  Reajuste Monetário - BACEN
  2025-08-11  1000.00    Transferência de Crédito

Supported account types: CashFlowBBCC, CashFlowBBCCPJ, CashFlowBBPP, CashFlowNUCredit.


Cash flow analysis

Compute monthly and yearly summaries from a canonical cash flow file.

from babilonia.accounting import CashFlow

cf = CashFlow()
cf.load_data("./caixa_diario.csv")

dc = CashFlow.get_cashflow_report(df=cf.data, year=2025, initial_cash=5000.0)
print(dc["Summary"])
print(dc["Pannel"])
   Ano   Categoria     Total     Media  % Entradas
  2025    ENTRADAS  18200.00   1516.67      100.00
  2025      SAIDAS  -9430.00   -785.83       51.81
  2025     Moradia  -3200.00   -266.67       17.58
  2025  Alimentacao  -1800.00   -150.00        9.89

   Mes  Entradas   Saidas    Fluxo      Saldo
2025-01   1500.0  -780.0    720.0     5720.0
2025-02   1500.0  -810.0    690.0     6410.0
     ...

Parse NFSe XML

Load and inspect a Nota Fiscal de Serviços Eletrônica from nfse.gov.br.

from babilonia.accounting import NFSe

nf = NFSe()
nf.load_data("./nfse.xml")
print(nf.date)           # '2025-09-01'
print(nf.emitter)        # '27543216700666 -- PRESTADOR LTDA'
print(nf.taker)          # '07704429000666 (CNPJ) -- TOMADOR LTDA'
print(nf.service_value)  # 6666.0

Batch-load NFSe files

Aggregate a folder of NFSe XML files into a single catalog.

from babilonia.accounting import NFSeColl

coll = NFSeColl()
coll.load_folder("./notas_fiscais/")
print(coll.catalog[["name", "Date", "ValorServico", "Prestador"]])
          name        Date  ValorServico                          Prestador
  NFSe_NF0080  2025-09-01        6666.0  27543216700666 -- PRESTADOR LTDA
  NFSe_NF0081  2025-10-01        5000.0  27543216700666 -- PRESTADOR LTDA

Command-line tools

The babilonia.tools scripts form a processing pipeline: raw exports → standardized files → cash flow reports.

Standardize raw bank exports

Reads T0 raw CSV files and writes T1 canonical CSVs in the same folder tree.

python -m babilonia.tools.parse --folder ./data --type bb-cc --year 2025

Available --type values: bb-cc, bb-pp, bb-ccpj, bb-cdb, nubank-credito.


Build cash flow reports

Aggregates T1 files into daily, monthly, and annual summaries. Omit --year to process all years.

python -m babilonia.tools.cashflow --folder ./data --type bb-cc

Categorize and report by label

Fills the Categoria column using a keyword dictionary, then prints and exports a monthly breakdown by category.

python -m babilonia.tools.categorize --folder ./data --type nubank-credito --year 2025

Yearly cash flow report

Reads the consolidated daily file and prints a formatted yearly panel and category summary.

python -m babilonia.tools.report --folder ./data --type bb-cc --year 2025

Release files for babilonia 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for babilonia 1.0.6
File Size Uploaded
babilonia-1.0.6.tar.gz 131.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for babilonia 1.0.6
File Interpreter ABI Platform
babilonia-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 199.3 kB

Release files / babilonia-1.0.6.tar.gz

Download URL babilonia-1.0.6.tar.gz
Size 131.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ff309a15eddd4d016305321b32fea3b2109417d7b07a2a3d3ca264f465373ce5
BLAKE2b-256 checksum
How to use checksums
6d47dc04d2cc294fabee93ee579a3f683c0f3ca39c6475d10a1de28fb646c309
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / babilonia-1.0.6-py3-none-any.whl

Download URL babilonia-1.0.6-py3-none-any.whl
Size 67.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
823e7c27d0d374c4748fb89bd1adf6010c90ae6d32afb4734324a29070af3f2c
BLAKE2b-256 checksum
How to use checksums
f7ef1197e32ec9d369d61297adb23d2ac10b0ffe10a32ff3dda35d612b414c41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page