タブ区切りやセミコロン区切りのデータを変換する
- 選ぶ
- 変換する
CSVという名前でも、区切りがカンマとは限りません。タブで区切られたデータや、セミコロンで区切られたデータもあります。CSVとJSONを相互変換する では、「区切り文字(CSV)」を選んで、変換できます。
手順
- 「変換の向き」を選びます。
- 「区切り文字(CSV)」で、「カンマ」「タブ」「セミコロン」から選びます。
- 「変換前」に、データを貼り付けます。
- 「変換する」を押して、結果を確認します。
3つの区切り文字
- カンマ(,):一般的なCSV。
- タブ:Excelやスプレッドシートからコピーしたデータ。TSVとも呼ばれる。
- セミコロン(;):ヨーロッパの国などで使われるCSV。小数点にカンマを使う国で多い。
見分け方
貼り付けたデータを見て、項目のあいだが、何で区切られているか確認します。
- 項目がカンマで区切られている → カンマ
- 項目のあいだに、広い空きがある(タブ)→ タブ
- 項目がセミコロンで区切られている → セミコロン
区切り文字が合っていないと
全体が1つの項目になってしまい、きれいに分かれません。結果がおかしいときは、区切り文字を変えて、もう一度試します。
Excelからコピーするとき
- Excelで、変換したい範囲を選んで、コピーする。
- 「変換前」に貼り付ける。
- 区切り文字を「タブ」にして、変換する。
項目の中にカンマがあるとき
データの中に、カンマが含まれる場合(住所など)は、区切り文字を、タブに変えると安全です。または、項目をダブルクォーテーションで囲んだ形式にします。
向いている場面
- Excelのデータを、そのまま貼り付けて変換する
- 海外のシステムから出力されたCSVを、変換する
- 項目内にカンマを含むデータを扱う
例
Excelの表をコピーして貼り付けたが、うまく分かれなかった。区切り文字を「タブ」に変えたら、きれいに変換できた。
つまずきやすい点
- 全体が1つの項目になる:区切り文字が合っていない。
- 数値の小数点が混ざる:セミコロン区切りで、小数点がカンマの場合。
よくある質問
区切り文字は、自動で判断されますか?
自動では判断されません。自分で選びます。
まとめ
区切り文字をデータに合わせる。Excelからのコピーは、タブです。
CSVとJSONを相互変換するを使う(無料)あわせて使えるツール
- 重複した行を消す・並べ替える:重複した行を消して、並べ替えます。
- ファイルをZIPにまとめる:複数のファイルを、1つのZIPにまとめます。
- 文字数カウント(エントリーシート・レポート用):文章の文字数・行数・原稿用紙の枚数などを数えます。
同じツールの、ほかの解説
Converting Tab- or Semicolon-Separated Data
- Choose
- Convert
Even called CSV, the separator is not always a comma. There is data separated by tabs, and data separated by semicolons. In Convert CSV and JSON, you choose the "Delimiter (CSV)" and convert.
Steps
- Choose the "Direction".
- For "Delimiter (CSV)", choose from "comma", "tab" and "semicolon".
- Paste the data into "Before conversion".
- Press "Convert" and check the result.
The three delimiters
- Comma (,): ordinary CSV.
- Tab: data copied from Excel or spreadsheets. Also called TSV.
- Semicolon (;): CSV used in countries such as those in Europe, mostly where a comma is the decimal separator.
How to tell
Look at the pasted data and check what separates the items.
- Items separated by commas → comma
- A wide gap between items (tab) → tab
- Items separated by semicolons → semicolon
If the delimiter is wrong
The whole line becomes one item and doesn't split cleanly. If the result is odd, change the delimiter and try again.
When copying from Excel
- In Excel, select the range to convert and copy.
- Paste into "Before conversion".
- Set the delimiter to "tab" and convert.
When items contain commas
If the data contains commas (addresses, for example), changing the delimiter to tab is safer. Or use a format with items enclosed in double quotes.
Good for
- Pasting Excel data as it is and converting
- Converting CSV output from overseas systems
- Handling data whose items contain commas
Example
Copied and pasted an Excel table but it didn't split well. Changing the delimiter to "tab" converted it cleanly.
Common stumbling blocks
- The whole becomes one item: the delimiter doesn't match.
- Decimal points get mixed in: semicolon-separated with commas as decimal points.
Frequently asked questions
Is the delimiter detected automatically?
It is not detected automatically. You choose it.
Summary
Match the delimiter to the data. Copies from Excel are tab-separated.
Use "Convert CSV and JSON" (free)Tools that go well with this
- Remove Duplicate Lines and Sort a List: Remove duplicate lines and sort them.
- Make a ZIP File: Pack several files into one ZIP.
- Character Counter (for Applications and Reports): Count characters, lines and manuscript sheets of your text.