Building the Activity Code Analyzer

The Activity Code Analyzer (actcod) is a Python data pipeline built during the Santander internship to categorize millions of banking transactions by their activity codes (COD_ACT). It maps raw numeric codes to business categories using a reference CSV, with support for multiprocessing to handle large transaction files efficiently.

What it does

The pipeline reads transaction data and a reference mapping file (referencias.csv), then:

  1. Loads references — Parses a CSV with Categorias and codigos columns, building a dictionary mapping each integer code to one or more business categories.
  2. Processes transactions — Reads transaction files and looks up each row’s activity code against the reference map.
  3. Fuzzy matching — Uses difflib.SequenceMatcher for near-matches when exact code lookups fail.
  4. Multiprocessing — Distributes work across CPU cores via multiprocessing.Pool for throughput on large datasets.
  5. Exports results — Writes categorized output with timestamps and progress logging.

Two script versions ship in the repo:

  • Verbose.py — Full-featured pipeline with detailed logging, statistics, and multiprocessing
  • verboseOG.py — Earlier single-threaded prototype for validation

Context

This project grew out of the CodigosActividad exploratory work archived in the Santander internship repo (txtversion), where multiple algorithm versions (simple, advanced, SQL-based) were tested before converging on the validated multiprocessing approach in this repository.

Activity code categorization supports fraud detection, customer segmentation, and regulatory reporting — turning opaque numeric codes into actionable business categories.

Tech stack

LayerChoice
LanguagePython 3
DataPandas
Matchingdifflib.SequenceMatcher, regex
Performancemultiprocessing.Pool, cpu_count()
I/OCSV read/write, JSON export

Development process

PrimerVersion

Initial commit with the first working categorization script — basic reference loading and single-file transaction processing.

PrimeraVersionNoMutihilo

Refined logic without multiprocessing to validate correctness on smaller samples before scaling.

PrimeraVersionmultihilo

Added multiprocessing with Pool to parallelize transaction batches across available CPU cores.

VersionMultihilovalidada

Final validated multiprocessing version (Verbose.py) — tested against reference data with correct category mappings at scale. This is the production-ready script in the repo.

README update (main branch)

Updated project documentation on the default main branch (the code lives on master).

Blog

recent-work

Building Smartclic Demo

Modern landing page for a Mexican web development agency — React 19, Vite, Tailwind v4, GSAP scroll, 3D viewer, and bilingual ES/EN.

Read more →

Smartclic Demo

Landing page for a Mexican web agency — React 19, Tailwind v4, GSAP scroll, 3D viewer, and bilingual ES/EN.

How it was built →
border-home1