Omniscope Custom Blocks › Preparation/Streaming-Field-Renamer

Streaming Field Renamer

Renames the fields of the input from rename rules (current name, new name) written in the block or kept in a CSV file, working through the data in chunks so large inputs never have to fit in memory.

Preparation Python

Open the demo in Omniscope Download demo.ioz Sample data: bank-transactions.csv Sample data: rename-rules.csv Source on GitHub

Omniscope custom block · Preparation

One list of renames, written in the block or kept in a CSV file, applied to every export that needs them, however many records it has.

Python · pandas · nothing extra to install

The problem it solves

A bank's transaction export uses short technical names: acct_no, txn_dt, dr_cr, amt_gbp. Every project that reads the export needs the same readable names, and the exports can be large.

This block renames the fields from a list of rules, chunk by chunk, leaving the values alone.

How it works

What goes in

Bank transactions

24 invented transactions on three business accounts.

acct_no txn_dt txn_ref dr_cr amt_gbp bal_gbp mcc
40-12-77 31845622 2025-05-01 CARD Fuel North Road DR 60.99 2439.01 5541
40-12-77 51200981 2025-05-01 FPO Rent Moor Lane DR 850.00 1650.00
20-44-19 70033415 2025-05-02 DD Pennine Water DR 30.55 2469.45 4900

24 rows in the sample file.

Rename rules (also in rename-rules.csv)

Current Name New Name
acct_no Account Number
txn_dt Transaction Date
txn_ref Reference
dr_cr Debit or Credit
amt_gbp Amount
bal_gbp Balance
mcc Merchant Category
branch_cd Branch Code

The options

Option Demo setting What it does
Rename rules acct_no = Account Number; txn_dt = Transaction Date; ... (all 8 rules) The rules, written in the block: Current Name = New Name, separated by semicolons or line breaks.
Rename rules CSV file empty The same rules as a CSV file (Current Name, New Name), used when Rename rules is empty.

What comes out

Renamed data

Account Number Transaction Date Reference Debit or Credit Amount Balance Merchant Category
40-12-77 31845622 2025-05-01 CARD Fuel North Road DR 60.99 2439.01 5541
40-12-77 51200981 2025-05-01 FPO Rent Moor Lane DR 850.00 1650.00
20-44-19 70033415 2025-05-02 DD Pennine Water DR 30.55 2469.45 4900

24 records, the fields in their original order.

Where it pays off

Finance: Bank and card exports

Give each bank's or card provider's export the same readable names before the transactions are appended and reconciled.

Large extracts: Logs and event data

Rename the fields of large extracts without holding them in memory at once.

Several projects: One rules file

Point every project that reads a system's exports at the same rules file, and update the names once.

System migrations: Old names to new

Rename the fields of an old system's extracts to the new system's names, so old and new data can be appended.

Use cases describe typical scenarios and are illustrative; the sample data is invented.

Why do this in Omniscope

How it fits into an Omniscope workflow

Bank export (File) → Streaming Field Renamer → Append (other banks' exports, renamed the same way) → Report

Try it

  1. Open the demo project (demo.iox on the demo server, or import demo.ioz from this folder): 24 bank transactions, with the rules written in the block.
  2. The question: can every project use the same readable names for this export?
  3. Open Streaming Field Renamer: the eight rules are in Rename rules. Run it.
  4. Look at the output: 24 records with all 7 fields renamed; the branch_cd rule is ignored because the export has no such field.
  5. Delete Amount from the rule amt_gbp = Amount and run again: the block stops with "These rules have no new name: amt_gbp".

Running in Omniscope

Omniscope workflow
Omniscope workflow

The demo project's workflow: the sample data, the block, and a Validate data check on its output.

Language and libraries

Python. It uses pandas.

pandas is part of Omniscope's Python environment. It needs nothing else installed.

Tested

The block is covered by automated tests that run its script against a stand-in for Omniscope's Python API: the sample data, data in several chunks, the block closing after the stream, rules files with spaces after commas, capitals in headings and a byte order mark, exact matching and ignored rules, renames that would clash, swapped names, blank, incomplete and duplicate rules, names that look like numbers or placeholders, unreadable or wrong rules files, rules written in the block (the same result as the file, one per line, precedence over the file, mistakes), empty input, field types kept, and 200,000 records with 500 fields.

Reference

Options

NameTypeWhat it does
Rename rulesTextRules written in the block, one per line or separated by semicolons: Current Name = New Name. Takes precedence over the file.
Rename rules CSV fileFileA CSV file with the columns Current Name and New Name, one rule per field to rename. UTF-8 text; the first line holds the column headings. Used when Rename rules is empty.

Outputs

OutputWhat it holds
RenamedThe input with its fields renamed by the rules; values unchanged.