Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Cómo comprobar que un CSV contable cuadra antes de importar

Si un despacho recibe un fichero con varias líneas por asiento, comparar solo la suma global puede ocultar errores: dos asientos descuadrados en sentido contrario se compensan. Esta comprobación agrupa las líneas por asiento y conserva los identificadores como texto. Preparar un archivo de prueba El ejemplo supone un export con separador punto y coma, coma decimal y sin separador de miles. Un…

To ensure a CSV accounting file balances before importing, a comprehensive check must be performed. Simply comparing global sums can conceal errors; two cancelling squared entries can hide discrepancies. This verification groups lines by transaction and retains identifiers as text.

To demonstrate, consider a sample export with semicolons as delimiters, decimal points, and no thousand separators. A €120 invoice is split into two rows, while the following invoice is short by €10. Here is the data:

asiento;debe;haber

0007;120,00;0

0007;0;120,00

0008;70,00;0

0008;0;60,00

The Python script validates this CSV using the following steps:

1. Import necessary modules: defaultdict, DictReader, Decimal, and InvalidOperation.

2. Define a function to convert raw amounts to Decimal objects, handling decimal points.

3. Define a balances function that reads the CSV file, checks required columns, calculates balances for each transaction, and returns balances with discrepancies.

The output for the test file diario.csv is {'0008': Decimal('10.00')}, indicating that only transaction 0008 requires review.

Balancing the debit and credit fields helps detect line losses, but a squared invoice may still have calculation or period errors. Retain the original file and expand the review process with additional controllable examples for Numio advisors. The provided example, generated with AI and tested with the sample CSV, ensures the verification process is robust.

Rewritten by urgent.news; may contain errors — check the original.

Read the original at dev.to →

Report a problem with this story

More in Tech

Standing on the Shoulders of Giants Takes a Harness

Part 3 of a series on engineering discipline in AI-assisted development, originally published on LinkedIn — Parts 1 and 2 are linked at the end.

  • AI-assisted development speeds up code generation but lacks quality control.
  • Organizations need a "harness" with development standards for AI benefits.
  • Harness includes sharing standards for consistent AI-human collaboration.

5 Best Chrome Extensions to Stop Doomscrolling & Filter Toxic News in 2026

We all know how browser doomscrolling starts: you open a tab to glance at major updates for two minutes, and thirty minutes later you are still scrolling through sensationalized headlines, partisan…

  • News Feed Eradicator removes algorithmic feeds from social media platforms
  • LeechBlock NG enables time-bound access control for specific websites
  • Doomscroll Blocker alerts users when scroll threshold is reached

More from Saturday 21 November →