0で始まる数字(郵便番号など)が消えるとき
- 確かめる
- 変換する
郵便番号「0123456」や、電話番号「09012345678」をCSVからExcelに取り込むと、先頭の0が消えてしまう。CSVをExcelファイルにする では、0で始まる数字を文字のまま入れるので、消えません。
手順
- 「CSVファイルを選ぶ」で、CSVを選びます。または、「CSVの内容」に貼り付けます。
- 「数字は数値として入れる」の設定を確認します。
- 「Excelにして保存」を押して、保存します。
0が消える原因
Excelは、数字として読める値を、自動で数値にします。数値の「007」は「7」として扱われ、先頭の0が消えます。CSVをExcelでそのまま開くと、この変換が起きます。
このツールの扱い
- 0で始まる数字:文字のまま保存。郵便番号、電話番号、会員番号、商品コードが守られる。
- ふつうの数字:数値として保存(「数字は数値として入れる」がオンのとき)。計算に使える。
0で始まる数字の例
- 郵便番号:0123456
- 電話番号:09012345678
- 会員番号・社員番号:000123
- 商品コード:00045
注意:計算に使えない
文字として入った数字は、足し算や平均などの計算には、使えません。計算したい数字(金額など)が0で始まっていて、文字になってしまった場合は、Excelで数値に変換します。
数値にしたくない数字
電話番号や、会員番号のように、計算しない数字は、文字のままが適切です。
向いている場面
- 顧客リストや、住所録のCSVを、Excelにしたい
- 商品コードを、そのまま保持したい
- 郵便番号の列を、崩したくない
例
会員番号が「000123」の形のCSVを、Excelにしたかった。普通に開くと「123」になったが、このツールを使うと、「000123」のまま保存された。
つまずきやすい点
- すでに0が消えたCSV:元のCSVの時点で、0が消えている場合は、戻せない。元のシステムで出力し直す。
- 数値の列も、文字になった:0で始まる値が混ざった列は、すべて文字になる場合がある。
よくある質問
小数点以下の数字(0.5など)は、どうなりますか?
「0.」で始まる小数は、数値として扱われます。
まとめ
0で始まる番号は、文字のまま守られる。計算する数字は、数値として入ります。
CSVをExcelファイルにするを使う(無料)あわせて使えるツール
- ExcelをCSV・JSONに変換する:Excelのシートを、CSV・TSV・JSONに変換します。
- CSVとJSONを相互変換する:CSVとJSONを、すぐに相互変換します。
- 重複した行を消す・並べ替える:重複した行を消して、並べ替えます。
同じツールの、ほかの解説
When Leading Zeros Disappear
- Check
- Convert
When postal codes like "0123456" or phone numbers like "09012345678" are brought from CSV into Excel, the leading 0 vanishes. In Convert CSV to Excel (.xlsx) numbers starting with 0 are entered as text, so they don't vanish.
Steps
- Choose the CSV with "Choose a CSV file", or paste into "CSV content".
- Check the setting "Enter numbers as numeric values".
- Press "Make Excel and save" and save.
Why the 0 vanishes
Excel automatically turns values that can be read as numbers into numeric values. The number "007" is treated as "7" and the leading 0 disappears. Opening a CSV directly in Excel triggers this conversion.
How this tool handles it
- Numbers starting with 0: stored as text. Postal codes, phone numbers, member numbers and product codes are protected.
- Ordinary numbers: stored as numeric values (when "Enter numbers as numeric values" is on). Usable in calculations.
Examples of numbers starting with 0
- Postal code: 0123456
- Phone number: 09012345678
- Member or employee number: 000123
- Product code: 00045
Caution: not usable in calculations
Numbers entered as text can't be used in calculations such as sums and averages. If a number you want to calculate with (such as an amount) starts with 0 and became text, convert it to a number in Excel.
Numbers you don't want as values
Numbers you don't calculate with, like phone numbers and member numbers, are appropriately kept as text.
Good for
- Turning customer lists and address-book CSVs into Excel
- Keeping product codes as they are
- Not wanting to corrupt a postal code column
Example
Wanted to make Excel from a CSV with member numbers in the form "000123". Opening normally gave "123", but with this tool it was saved as "000123".
Common stumbling blocks
- A CSV whose 0s have already vanished: if the 0 was lost already in the original CSV, it can't be restored. Output again from the original system.
- A numeric column also became text: a column with values starting with 0 mixed in may become all text.
Frequently asked questions
What about decimals like 0.5?
Decimals starting with "0." are treated as numeric values.
Summary
Numbers starting with 0 are protected as text. Numbers you calculate with go in as values.
Use "Convert CSV to Excel (.xlsx)" (free)Tools that go well with this
- Convert Excel to CSV or JSON: Convert an Excel sheet to CSV, TSV or JSON.
- Convert CSV and JSON: Convert between CSV and JSON instantly.
- Remove Duplicate Lines and Sort a List: Remove duplicate lines and sort them.