今日已更新 442 条资讯 | 累计 23078 条内容
关于我们

CSV is plain text until a spreadsheet guesses: preflight risky cells with PlainCell

Nekoautomata Miki 2026年07月18日 14:11 3 次阅读 来源:Dev.to

A CSV file can preserve every byte you exported and still look different after somebody opens and saves it in a spreadsheet. The problem is not always a broken parser. Spreadsheet applications deliberately interpret text during import. Depending on the application, version, locale, and import path, that can remove leading zeros, round long integer-like values, treat E notation as scientific notation, parse compact letter-and-digit tokens as dates, or reinterpret decimal and thousands separators. I released PlainCell to make those possible interpretations reviewable before the file is opened and saved. PlainCell is a zero-dependency, local, read-only Node.js CLI and browser workspace. It reports the exact source cell, physical line, column, original text, reason, and an explicit import recipe. It does not rewrite the CSV or claim to know what the value was intended to mean. A small example Consider this export: record_id,account_code,sample,reference,amount 1,00123,JAN1,1234567890123456,"1.234,56" 2,00007,12E5,9876543210987654,"19,95" Install PlainCell from the public Codeberg npm registry: npm install --global plaincell@0.1.0 \ --registry = https://codeberg.org/api/packages/automa-tan/npm/ Then run the preflight: plaincell risky.csv The bundled fixture reports eight possible interpretations across four columns. Those findings cover several separate risks: 00123 and 00007 may lose leading zeros if imported as numbers; 16-digit integer-like references may exceed the precision preserved by ordinary spreadsheet numeric cells; 12E5 may be interpreted as scientific notation; JAN1 may be interpreted as a compact date-like token; decimal-comma and mixed grouping/decimal text depend on the chosen import locale and separators. A finding means “review this cell and the import settings,” not “data loss definitely occurred.” PlainCell cannot infer whether a value is an identifier, a measurement, a date, or a typo. Provenance instead of a generic warning “Be careful opening CSV i

本文内容来源于互联网,版权归原作者所有
查看原文