Repository navigation
fix(core): register Excel misto numerico+stringa come VARCHAR - #511
Merged
Merged
Conversation
Le colonne object miste (numeri + stringhe, es. footer 'Applied filters' degli export Terna) fallivano al register pandas→DuckDB: DuckDB deduceva il tipo numerico dai valori dominanti e castava male la stringa. Stringifiche le colonne miste al register; i consumer SQL continuano a usare cast_int/cast_double.
Review finding: l'helper mutava in-place il DataFrame single-frame. Ora copia solo quando trova una colonna mista da stringificare; input mai mutato. Aggiunto test pure policy.
Gabrymi93
added a commit
to dataciviclab/energia-italia
that referenced
this pull request
Oct 16, 2026
L'export xlsx del Download Center Terna pagina con pageSize (default 100): bilancio-elettrico restituiva 100 paesi (A→K, mart UE 9/15) e elettricita-per-settore 100 righe (7 regioni, 25 province). - bilancio: pageSize=500 (209 paesi verificati; 2024/2025 non ancora pubblicati dalla fonte) - settore: pageSize=500000 come da notes (428 righe, 20 regioni, 107 province su tutti gli anni 2015-2024) Depende da dataciviclab/toolkit#511 per il re-run CI del 2015 (register Excel su colonne miste + footer).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sintesi
Il register pandas→DuckDB del reader Excel (
_execute_excel_read) falliva su colonne object miste numeri+stringhe: DuckDB deduceva il tipo numerico dai valori dominanti e castava male le stringhe residue. Ora le colonne miste vengono stringificate al register.Contesto collegato
Nessuna issue — regression trovata durante il fix di troncatura
pageSizeindataciviclab/energia-italia(datasetterna_elettricita_per_settore, export xlsx con riga footer "Applied filters: ..." nella prima colonna numerica).Cosa cambia
Impatto su contratti pubblici
dataset.yml(nuovo campo, cambio obbligatorietà)Verifica
pytest tests/test_clean_duckdb_read.py -q # 32 passed (1 nuovo regression policy) ruff check toolkit/core/read_excel.py tests/test_clean_duckdb_read.py mypy toolkit/core/read_excel.pypytestsul file toccato passaruff check .passamypy toolkit/sul modulo toccato passapolicy(test_read_excel_mixed_numeric_string_column_registers_as_varchar)Checklist PR
Note per chi revisiona
energia-italia(Terna xlsx) — fix sblocca il re-run 2015 diterna_elettricita_per_settoreconpageSize=500000.Metriche PR