CSV (comma separated values): Difference between revisions

From Tygron Support wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 13: Line 13:
You can create your own CSV file, as shown below:
You can create your own CSV file, as shown below:


We have a simple data set of some produce: 10 apples, 5 oranges, 1 tomatoe and 3 onions. We would like to create a table from a CSV file with headers that displays the name, type, color and quantity.
We have a simple data set of an inventory of produce: 10 apples for 0,80 a piece, 5 oranges for 1,20 a piece, 1 tomatoe for 0,75 a piece and 3 onions for 0,50 a piece. We would like to create a table from a CSV file with headers that displays the name, type, color and quantity.


We begin with the first line of column headers:
We begin with the first line of column headers:


<pre>name; type; color; quantity</pre>
<pre>name; type; quantity; price</pre>


Then we add the first data record:
Then we add the first data record on the next line:


<pre>name; type; color; quantity
<pre>name; type; quantity; price
apple; fruit; green; 10,0</pre>
apple; fruit; 10; 0,80</pre>


Now we add the other entries, resulting in a European CSV file, where the decimal separator is a comma and the value separator is a semicolon:
Now we add the other entries, resulting in a European CSV file, where the decimal separator is a comma and the value separator is a semicolon:


<pre>name; type; color; quantity
<pre>name; type; quantity; price
apple; fruit; green; 10,0
apple; fruit; 10; 0,80
orange; fruit; orange; 5,0
orange; fruit; 5; 1,20
tomatoe; vegetable; red; 1,0
tomatoe; vegetable; 1; 0,75
onion; vegetable; yellow; 3,0</pre>
onion; vegetable; 3; 0,50</pre>


This CSV file will result in a similar table as below, when importing the file in a spread sheet program:
This CSV file will result in a similar table as below, when importing the file in a spread sheet program:
Line 37: Line 37:
| name
| name
| type
| type
| color
| quantity
| quantity
| price
|-
|-
| apple
| apple
| fruit
| fruit
| green
| 10
| 10,0
| 0,80
|-
|-
| orange
| orange
| fruit
| fruit
| orange
| 5
| 5,0
| 1,20
|-
|-
| tomatoe
| tomatoe
| vegetable
| vegetable
| red
| 1
| 1,0
| 0,75
|-
|-
| onion
| onion
| vegetable
| vegetable
| yellow
| 3
| 3,0
| 0,50
|-
|-
|}
|}
Line 64: Line 64:
An example of the data as a USA/UK CSV file, where the decimal separator is a period and the value separator is a comma:
An example of the data as a USA/UK CSV file, where the decimal separator is a period and the value separator is a comma:


<pre>name, type, color, quantity
<pre>name, type, quantity, price
apple, fruit, green, 10.0
apple, fruit, 10, 0.80
orange, fruit, orange, 5.0
orange, fruit, 5, 1.20
tomatoe, vegetable, red, 1.0
tomatoe, vegetable, 1, 0.75
onion, vegetable, yellow, 3.0</pre>
onion, vegetable, 3, 0.50</pre>


Which will result in the following table:
Which will result in the following table:
Line 75: Line 75:
| name
| name
| type
| type
| color
| quantity
| quantity
| price
|-
|-
| apple
| apple
| fruit
| fruit
| green
| 10
| 10.0
| 0.80
|-
|-
| orange
| orange
| fruit
| fruit
| orange
| 5
| 5.0
| 1.20
|-
|-
| tomatoe
| tomatoe
| vegetable
| vegetable
| red
| 1
| 1.0
| 0.75
|-
|-
| onion
| onion
| vegetable
| vegetable
| yellow
| 3
| 3.0
| 0.50
|-
|-
|}
|}

Revision as of 09:11, 3 September 2020

What are comma separated values (CSV)?

CSV-logo2.jpg

CSV files are used to transfer data sets between information systems that do not use the same (propriarity) data format. For example, by using the CSV format, data from a data base in a propriarity format can be transferred to a spread sheet program with another propriarity format.

Comma separated values (CSV) is a specification of this tabulated data, where the data is stored on single lines in a text based file and entries are separated with a comma or other character.

In the Anglo Saxon influence sphere, commas are in use as separators. However, in the rest of the world commas are already in use as decimal separators and periods as thousand-separators, hence the use of semi colons in stead in these regions.

When copying an HTML table into memory, to paste it in plain text or spreadsheet, the tab character ('\t') is automatically used as separator.

A CSV file can be created and read with a simple text editor. The file consists of line entries that correspond with the rows in a spreadsheet. Each line (row) has the same number of (column) entries, separated with a comma or other separator. The first line can be used to name column headers of the resulting table. Lines are sometimes ended with only a line feed and no carriage return, which results in the text being displayed in a text editor as one single line without separation per table row. Spreadsheets can ususally read these line feeds without problem, ordering the data in its proper rows again.

You can create your own CSV file, as shown below:

We have a simple data set of an inventory of produce: 10 apples for 0,80 a piece, 5 oranges for 1,20 a piece, 1 tomatoe for 0,75 a piece and 3 onions for 0,50 a piece. We would like to create a table from a CSV file with headers that displays the name, type, color and quantity.

We begin with the first line of column headers:

name; type; quantity; price

Then we add the first data record on the next line:

name; type; quantity; price
apple; fruit; 10; 0,80

Now we add the other entries, resulting in a European CSV file, where the decimal separator is a comma and the value separator is a semicolon:

name; type; quantity; price
apple; fruit; 10; 0,80
orange; fruit; 5; 1,20
tomatoe; vegetable; 1; 0,75
onion; vegetable; 3; 0,50

This CSV file will result in a similar table as below, when importing the file in a spread sheet program:

name type quantity price
apple fruit 10 0,80
orange fruit 5 1,20
tomatoe vegetable 1 0,75
onion vegetable 3 0,50

An example of the data as a USA/UK CSV file, where the decimal separator is a period and the value separator is a comma:

name, type, quantity, price
apple, fruit, 10, 0.80
orange, fruit, 5, 1.20
tomatoe, vegetable, 1, 0.75
onion, vegetable, 3, 0.50

Which will result in the following table:

name type quantity price
apple fruit 10 0.80
orange fruit 5 1.20
tomatoe vegetable 1 0.75
onion vegetable 3 0.50

Most programs that can receive CSV files, provide an option to select the locality (USA/UK vs European), when importing the file.

CSV (comma separated values) and the Tygron Geodesign Platform

Link to attribute arrays You can use , ; \t etc Csv can contain 10.000 time steps

See also

Importeren en exporteren van grote hoeveelheden data met .csv en timestamps (Dutch only)

How to load in dynamic rain and simulation time (Water Overlay)
How to set dynamic breach height
How to load in dynamic evaporation rate (Water Overlay)