Rabu, 12 Maret 2025

CSV On The Web 1

CSV ( Comma Separated Values ) is one of the most popular formats for publishing data on the web. It is concise, easy to understand by both humans and computers, and aligns nicely to the tabular nature of most data.
But there is no mechanism within CSV to indicate the type of data in a particular column, or whether values in a particular column must be unique. It is therefore hard to validate and prone to errors such as missing values or differing data types within a column.

Tabular data is any data that can be arranged in a table, like the one here:

Example Table Data or Tabular Data

column 1 column 2 column 3
row 1 cell in column 1 and row 1 cell in column 2 and row 1 cell in column 3 and row 1
row 2 cell in column 1 and row 2 cell in column 2 and row 2 cell in column 3 and row 2
row 3 cell in column 1 and row 3 cell in column 2 and row 3 cell in column 3 and row 3


A CSV file writes each row on a separate line and each cell is separated from the next with a comma. The values of cells can be written with double quotes around them; this is necessary when a cell value contains a line break or a comma.

Example Easy CSV file

cell in column 1 and row 1,cell in column 2 and row 1,cell in column 3 and row 1
cell in column 1 and row 2,cell in column 2 and row 2,cell in column 3 and row 2
cell in column 1 and row 3,cell in column 2 and row 3,cell in column 3 and row 3

Example CSV file With Double Quotes Around Cell Values:

"cell in column 1 and row 1","cell in column 2 and row 1","cell in column 3 and row 1"
"cell in column 1 and row 2","cell in column 2 and row 2","cell in column 3 and row 2"
"cell in column 1 and row 3","cell in column 2 and row 3","cell in column 3 and row 3"

Example CSV file that contains a header row:

"country","country group","name (en)","name (fr)","name (de)","latitude","longitude"
"at","eu","Austria","Autriche","Österreich","47.6965545","13.34598005"
"be","eu","Belgium","Belgique","Belgien","50.501045","4.47667405"
"bg","eu","Bulgaria","Bulgarie","Bulgarien","42.72567375","25.4823218"

Example CSV file 

Column titles are a type of annotation on a column, not part of the data itself. For example, they aren't included when you're counting the rows of data in a table:

column 1 column 2 column 3 column 4 column 5 column 6 column 7
titles country country group name (en) name (fr) name (de) latitude longitude
row 1 AT eu Austria Autriche Österreich 47.6965545 13.34598005
row 2 BE eu Belgium Belgique Belgien 50.501045 4.47667405
row 3 BG eu Bulgaria Bulgarie Bulgarien 42.72567375 25.4823218

CSV Metadata File

Example the simplest CSV metadata file in JSON

 you can create a single table description in JSON file (for file name e.g. countries.json) and looks like:
{
  "@context": "http://www.w3.org/ns/csvw",
  "url": "countries.csv"
}
Metadata files must always include the @context property with a value "http://www.w3.org/ns/csvw": this enables implementations to tell that these are CSV metadata files. The url property points to the CSV file that the metadata file describes.

NOTE

These metadata documents should be served from a web server with a media type of application/csvm+json if possible.

Example the table contains seven columns named

table metadata in JSON as they are in this CSV file like so:
{
  "@context": "http://www.w3.org/ns/csvw",
  "url": "countries.csv"
  "tableSchema": {
    "columns": [{
      "titles": "country"
    },{
      "titles": "country group"
    },{
      "titles": "name (en)"
    },{
      "titles": "name (fr)"
    },{
      "titles": "name (de)"
    },{
      "titles": "latitude"
    },{
      "titles": "longitude"
    }]
  }
}

Bibliography

https://www.w3.org/
https://www.convertcsv.com/

Related Post

Tidak ada komentar:

Posting Komentar