# CSVの先頭の0や長い数字を消さずに保持

> 郵便番号、商品番号、長いIDは全桁そのまま。価格や金額は合計できる数値のままです。

Human page: https://unmakelabs.com/ja-jp/csv-keep-leading-zeros/. This is the version for AI agents.

## What it does

CSVで先頭の0が消えない。桁も一つも失いません。 郵便番号、商品番号、長いIDは全桁そのまま。価格や金額は合計できる数値のままです。

## Excelで桁が消える理由

CSVをダブルクリックで開くと、Excelは数字に見えるものをすべて数値に変換します。02134は2134になり、JAN（EAN）コードは4.00638E+12になり、16桁のカード番号や注文IDは最後の1桁が失われて元に戻せません。Excelは15桁までしか保持しないためです。このツールはコード（先頭の0、同じ長さの12桁以上の数字、+から始まる電話番号）を見分けて文字列として保存するので、何も変わりません。

## 出力されるもの

合計できる本物の数値、並べ替えできる本物の日付、全桁を保持したコードを含むExcelファイルです。郵便番号や商品番号は先頭の0がそのまま残り、JAN（EAN）コード、IBAN、16桁のIDも書かれたとおりに保持されます。先頭行は見出しとして固定され、表の上にある説明行も残ります。ほかに、Excelで正しく開けるCSVや、インポート用のシンプルなUTF-8 CSVも出力できます。

## Facts

- **修正内容:** 文字コード（UTF-8、Windows-1252、UTF-16、Mac、「Ã¼」のような文字化け）、区切り文字、小数点のカンマ・ピリオド、日付、先頭の0、長い数字
- **保存形式:** Excel .xlsx、Excel用CSV、シンプルなUTF-8 CSV、JSON。ExcelからCSVへの変換も可能
- **チェック:** Excelファイルからすべてのセルを読み戻し、桁落ちがないことを確認。行数と列数も照合
- **プライバシー:** お使いの端末上で読み込み、アップロードは一切ありません

## How a person does it

1. **CSVをドロップ.** または「CSVファイルを選択」をタップします。銀行、ネットショップ、オープンデータなどから書き出した数MBのファイルなら約1秒で処理できます。
2. **変換前後を比較.** 上段はExcelでダブルクリックしたときの表示、下段は修正後の表で、変更されたセルには色が付きます。必要に応じて「調整」で列の種類を変更できます。
3. **Excelファイルをダウンロード.** 「ダウンロード」をタップします。ページ側でファイルを読み戻し、すべてのセルを確認済みです。

## Open a file by link (works today)

The viewer runs in a browser. Any public file URL can be opened by adding `?src=` (URL-encoded): `https://unmakelabs.com/ja-jp/csv-keep-leading-zeros/?src=https://unmakelabs.com/apps/csvfix/samples/marches-publics.csv`. The host must allow cross-origin reads (GitHub raw, most object storage and CDNs do). A camera view can be added after `#`: none: the file never goes in a link. `?src=<public CSV URL>` opens a file the visitor's browser can fetch (CORS).

Embed: `<iframe src="https://unmakelabs.com/embed/csvfix/?src=<url-encoded file URL>" width="100%" height="480" style="border:0"></iframe>`.

## Send your own file (live)

`POST https://y64b3d8qbc.execute-api.eu-central-1.amazonaws.com/v1/csv_fix/jobs?wait=25` with the file as multipart `file` (or JSON `file_base64` + `filename`, or `file_url`), API tool `csv_fix`: Fix a CSV for Excel (encoding, separator, decimals, dates, leading zeros). The same engine code as this page. No sign-up; Free: 5 full results per IP per day without a key (resets at 00:00 UTC); POST /v1/keys gives an instant key with 25 more full results (one-time, not renewed); each accepted correction adds 1 free call (up to 20 a month). Options (JSON in `options`): `locale`: e.g. de-de: separator/decimal of the CSV-for-Excel file and the date-order fallback (default en-us); `encoding`: force an encoding (utf-8, windows-1252, iso-8859-15, windows-1250, macintosh, utf-16le); `delimiter`: force the separator (; , | or a tab); `header`: header row index, -1 for none; `types`: per column: {"3": "text"|"number."|"number,"|"DMY"|"MDY"}.

```bash
# CSV to a typed .xlsx + report
curl -s -F "file=@export.csv" -F 'options={"locale":"de-de"}' "https://y64b3d8qbc.execute-api.eu-central-1.amazonaws.com/v1/csv_fix/jobs?wait=25"
```

## Good to know

判定は自動で行われ、その理由は「詳細」に表示されます。日付の日が12以下しかない場合、日と月のどちらが先かはファイル内のほかの部分から推定します。その列には印が付き、ワンタップで切り替えられます。18か国の実際の公開CSVデータ74件と、生成した200件のファイルでテスト済みです。Excelファイルからすべてのセルを読み戻し、桁落ちはありませんでした。

## Not done by this tool

- データ自体は変更しません。正しく読み込むだけで、クレンジングや重複削除は行いません
- 50 MBを超えるファイルはブラウザで開けません
- PDF（「PDFの表をExcelに」をご利用ください）や古い.xlsは読み込めません
- 複数のCSVファイルの結合はできません

## Value

Fixes a CSV so it opens right in Excel, in the browser: reads the encoding from the bytes (UTF-8 with or without BOM, UTF-16, Windows-1252, ISO-8859-15, Windows-1250, Mac Roman) and repairs double-encoded UTF-8 (Ã¼ -> ü); finds the separator (; , tab |) from consistent field counts with quotes respected, and the header row under junk lines; types each column: numbers in any writing (1.234,56 / 1,234.56 / 1'234.50 / 1 234,5 / (12.30) / 12,50- / 5 % / currency), dates (ISO, d.m.y, d/m/y vs m/d/y decided per column, 2-digit years), and text that must stay text (leading zeros, 12+ digit codes such as EAN, SIRET, IBAN, +phone numbers). Shows the file as Excel shows it on a double-click next to the fixed table with every changed cell marked. Saves .xlsx with typed cells (numbers, dates, protected text), CSV for Excel in the visitor's language, plain UTF-8 CSV, Windows-1252 CSV or JSON; also turns an .xlsx into a CSV for an import system. Before download the page reads its own .xlsx back and compares every cell, checks that no digit was lost and that rows and columns match; otherwise the download is blocked. Nothing is uploaded. Free, no sign-up.

## When it fits

- Someone double-clicks a bank, shop, CRM or open-data CSV and Excel shows one column, Ã¼ instead of ü, dates in place of numbers or postcodes without their leading 0.
- Someone needs a CSV export from another country (semicolon vs comma, decimal comma vs point) as a working spreadsheet.
- Someone has an Excel sheet and needs a CSV with a given separator, decimal mark and encoding for an import system.

### When not

- Cleaning, deduplicating or reshaping data (the tool reads data right; it does not change it).
- PDF tables (use the PDF tables tool) or old binary .xls files; files over 50 MB in the browser.

## Why use it instead of the alternatives

- Nothing to install: the tool opens a public CSV by link (?src=) in any browser, phones included, and can be embedded (/embed/csvfix/).
- Excel's own import (Data > From Text/CSV) asks for encoding, separator and each column's type by hand; online converters mostly upload the file and convert the encoding only, leaving decimal commas, dates and leading zeros to Excel.
- This tool detects all of it from the file, shows before and after, keeps every digit and proves the result cell by cell, without an upload or an account.

### What rebuilding it would take

- Detect the encoding, separator and header row of each file, and repair double-encoded text.
- Type every column by locale-aware number and date rules, keeping codes with leading zeros or 12+ digits as text.
- Write an .xlsx with number formats and read it back to prove every cell, plus a simulation of Excel's double-click to show what was wrong.
- Plus a test set of generated and real public CSVs from many countries, scored by program.

## Quality

No score published; the limits above say what it does not do. Check results that matter before you rely on them.

## Risk for the user

- Free and unlimited; no sign-up, no ads.
- Files are read on the user's device and never uploaded.

_Status: CSV/TSV/TXT -> .xlsx, CSV for Excel, plain CSV, JSON, and .xlsx -> CSV work in the browser; agents send their own file to POST https://y64b3d8qbc.execute-api.eu-central-1.amazonaws.com/v1/csv_fix/jobs?wait=25._

## Privacy

- Files are read on the user's device and not uploaded; there is no share link for files.
- The page loads Papa Parse and fflate from unmakelabs.com itself; no third-party code host is contacted.

## Data

ブラウザ内で開き、ファイルはお使いの端末から出ません。アップロードは一切なく、ファイルの情報がリンクに含まれることもありません。

## FAQ

- **ExcelでCSVを開くときに先頭の0が消えないようにするには？** ここにCSVをドロップして.xlsxをダウンロードしてください。先頭に0がある列は文字列として保存されるため、02134は02134のままです。金額の列は本物の数値のままです。
- **Excelで数字が1.23E+15のように表示されるのはなぜですか？** 11桁を超える数字は指数表示になり、16桁以上になるとExcelは桁を切り捨てます。このツールではこうしたコードを文字列として保持し、全桁そのまま残します。
- **ダウンロード前にチェックを待つのはなぜですか？** 黙って1桁でも落とす変換ツールは、ないほうがましだからです。ページはExcelファイルを書き出したあと読み戻し、すべてのセルをCSVと比較します。1つでも違いがあればダウンロードは止まり、どこが違うかが表示されます。
- **インポート用にExcelファイルをCSVに変換できますか？** はい。ここに.xlsxをドロップし、「調整」で取り込み先のシステムに合わせた区切り文字、小数点、日付の形式、文字コードを選んでから、CSVをダウンロードしてください。
- **本当に無料ですか？** はい。広告なし、登録不要、制限もありません。
- **ファイルはアップロードされますか？** いいえ。ファイルはお使いの端末上で、このページ内で読み込まれます。アップロードも、ファイルの共有リンクもありません。
- **AIエージェントでも使えますか？** エージェントはリンクを使って公開CSVをこのツールで開けます（このページのURLに ?src= とファイルのアドレスを付けます）。修正済みファイルとJSONレポートを返すサーバー版は準備済みで、まだ公開していません。
- **運営者は？** Unmake Labs（Julien Salomon）です。お問い合わせ：hello@unmakelabs.com

## Related pages

- [CSVをエクセルで列に分けて開く](https://unmakelabs.com/ja-jp/open-csv-in-excel/)
- [CSVの文字化けを直す（UTF-8）](https://unmakelabs.com/ja-jp/fix-csv-encoding/)
