Warm tip: This article is reproduced from serverfault.com, please click

Trouble rendering CSV data as an interactive table in GitHub

发布于 2020-11-30 13:49:46

When viewed, any .csv file committed to a GitHub repository automatically renders as an interactive table, complete with headers and row numbering. By default, the first row is your header row. The tables were supposed to look nice as below:

enter image description here

However, there's an error happening in my tabular data, and despite indicating the error, I can't fix it:

enter image description here

enter image description here

I'm using a csv file with a semicolon separator. Would anyone have an idea of what's happening?

Many thanks.

Questioner
Naomi
Viewed
0
ocrdu 2020-12-01 19:41:42

According to the docs, Github can only do its lay-out thing with .csv (comma-separated) and .tsv (tab-separated) files.

Using a semicolon as a separator isn't supported, at least not officially, and a spurious comma in a semicolon-separated file could well throw the algorithm off.

You could try replacing all semicolons with tabs and see how you fare.

If that doesn't work, try using commas as separators and enclose all text table cell data with quotes, like:

"Liver fibrosis, sclerosis, and cirrhosis","c370800","102922","Cystic fibrosis related cirrhosis","Diagnosis of liver fibrosis, sclerosis, and cirrhosis"

Note: no spaces after the commas. Also, if you have quotes in the text fields, you will have to escape those to "" (two quotes), or the algorithm will get confused.

You may get away with using quotes only for the offending text data, but that could well be more difficult to generate than just putting the quotes around all fields.