タブ区切りやセミコロン区切りを変換する
- 選ぶ
- 変換する
CSVという名前でも、区切りがカンマとは限りません。タブや、セミコロンで区切られたデータもあります。CSVをExcelファイルにする では、「区切り文字」を選んで、正しく列に分けられます。
手順
- 「CSVファイルを選ぶ」で、ファイルを選びます。または、「CSVの内容」に貼り付けます。
- 「区切り文字」で、種類を選びます。「自動で判定」「カンマ」「タブ」「セミコロン」。
- 「Excelにして保存」を押します。
3つの区切り文字
- カンマ(,):一般的なCSV。
- タブ:Excelなどからコピーしたデータ。TSVとも呼ばれる。
- セミコロン(;):ヨーロッパなどで使われるCSV。小数点にカンマを使う国で多い。
自動判定で足りるとき
データの1行目を見て、どの区切りが使われているか、自動で判定されます。多くの場合は、自動で正しく判定されます。
手動で選ぶとき
- 自動判定で、列が正しく分かれなかった
- データの中に、複数の種類の区切りが含まれる
- 確実に指定したい
区切りが合っていないと
全体が1列になってしまい、きれいに分かれません。結果の列を見て、おかしければ、区切り文字を変えてもう一度試します。
項目の中にカンマがある場合
住所などに、カンマが含まれる場合は、項目がダブルクォーテーションで囲まれていれば、正しく処理されます。囲まれていない場合は、タブ区切りで出力し直すのが安全です。
向いている場面
- 海外のシステムから出力された、セミコロン区切りのCSV
- Excelからコピーした、タブ区切りのデータ
- データベースから出力した、タブ区切りのデータ
例
海外の通販サイトから出力した注文CSVが、1列にまとまって開いた。セミコロン区切りだったため、区切り文字を「セミコロン」にして変換したところ、正しい列に分かれた。
つまずきやすい点
- 一部の列だけずれる:項目内の区切り文字が、引用符で囲まれていない。
- 小数点がカンマ:セミコロン区切りのCSVで、数値の小数点がカンマの場合、数値として扱われない場合がある。
よくある質問
他の区切り文字(スペースなど)は使えますか?
このツールは、カンマ、タブ、セミコロンに対応しています。
まとめ
迷ったら「自動で判定」。ずれるときは、区切り文字を手動で選びましょう。
CSVをExcelファイルにするを使う(無料)あわせて使えるツール
- ExcelをCSV・JSONに変換する:Excelのシートを、CSV・TSV・JSONに変換します。
- CSVとJSONを相互変換する:CSVとJSONを、すぐに相互変換します。
- 重複した行を消す・並べ替える:重複した行を消して、並べ替えます。
同じツールの、ほかの解説
Converting Tab- or Semicolon-Separated Data
- Choose
- Convert
Even called CSV, the separator is not always a comma. There is data separated by tabs or semicolons. In Convert CSV to Excel (.xlsx) you choose the "Delimiter" and split into columns correctly.
Steps
- Choose a file with "Choose a CSV file", or paste into "CSV content".
- Choose the type under "Delimiter": "Detect automatically", "Comma", "Tab" or "Semicolon".
- Press "Make Excel and save".
The three delimiters
- Comma (,): ordinary CSV.
- Tab: data copied from Excel and the like. Also called TSV.
- Semicolon (;): CSV used in places like Europe, mostly in countries using a comma as the decimal separator.
When automatic detection is enough
It looks at the first line of the data and detects which delimiter is used. In most cases it detects correctly.
When to choose manually
- Automatic detection didn't split columns correctly
- The data contains several kinds of delimiters
- You want to specify it for certain
If the delimiter doesn't match
The whole line becomes one column and doesn't split cleanly. Look at the resulting columns, and if odd, change the delimiter and try again.
When items contain commas
If addresses and the like contain commas, they are handled correctly as long as the items are enclosed in double quotes. If not enclosed, it's safer to output again as tab-separated.
Good for
- Semicolon-separated CSVs output from overseas systems
- Tab-separated data copied from Excel
- Tab-separated data output from databases
Example
An order CSV output from an overseas shop opened as a single column. It was semicolon-separated, so converting with the delimiter set to "Semicolon" split it into the right columns.
Common stumbling blocks
- Only some columns shift: delimiters inside items aren't enclosed in quotes.
- Decimal point is a comma: in semicolon-separated CSV where decimals use commas, numbers may not be treated as values.
Frequently asked questions
Can other delimiters (such as spaces) be used?
This tool supports commas, tabs and semicolons.
Summary
If unsure, "Detect automatically". If columns shift, choose the delimiter manually.
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.