CSV (comma separated values): Difference between revisions
Line 161: | Line 161: | ||
==See also== | ==See also== | ||
===Import CSV=== | |||
[[File:YoutubeLogo1.jpg|thumb|left|link=https://youtu.be/GnTkziMUyIU|Importeren en exporteren van grote hoeveelheden data met .csv en timestamps (Dutch only)]]{{clear}} | [[File:YoutubeLogo1.jpg|thumb|left|link=https://youtu.be/GnTkziMUyIU|Importeren en exporteren van grote hoeveelheden data met .csv en timestamps (Dutch only)]]{{clear}} | ||
*[[How to import a time sequence with a CSV]]<br> | |||
*[[How to load in dynamic rain and simulation time (Water Overlay)]]<br> | *[[How to load in dynamic rain and simulation time (Water Overlay)]]<br> | ||
*[[How to set dynamic breach height]]<br> | *[[How to set dynamic breach height]]<br> | ||
*[[How to load in dynamic evaporation rate (Water Overlay)]] | *[[How to load in dynamic evaporation rate (Water Overlay)]]<br> | ||
===Export CSV=== | |||
*[[How to export objects of the 3D world as CSV]] |
Revision as of 09:24, 4 September 2020
CSV files are used to transfer data sets between information systems that do not use the same (proprietary) data format. For example, by using the CSV format, data from a data base in a proprietary format can be transferred to a spread sheet program with another proprietary 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 and periods as decimal separators. In the rest of the world commas are already in use as decimal separators and periods as thousand-separators. In these regions semi-colons are used in stead of commas as value separator in a CSV file.
Another variation in separator characters is when copying an HTML table into memory. When pasting it in plain text, the tab character ('\t') is automatically used as separator in stead of a comma or semi-colon.
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 (columns) 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.
Creating a CSV file
We have a simple data set of a list of produce: 10 apples for 0,80 a piece, 5 oranges for 1,20 a piece, 1 tomato 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 columns with headers that display the name, type, color and quantity of each record.
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 tomato; vegetable; 1; 0,75 onion; vegetable; 3; 0,50
Save the text file with ".csv" as extention, to save it as a CSV file and not as a regular text file.
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 |
tomato | 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 tomato, 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 |
tomato | vegetable | 1 | 0.75 |
onion | vegetable | 3 | 0.50 |
Most programs that can receive CSV files, provide an option to select what to use as separator when importing the file.
CSV (comma separated values) and the Tygron Geodesign Platform
CSV files can be used to transfer (import) data into the Tygron geodesign Platform, or to extract (export) data from the platform. As there are many areas with this functionality in the platform, only some examples will be explained here. Below this article are links to other articvles on this wiki with more information about specific situations.
Importing a CSV file in the Tygron Geodesign Platform
The CSV data structure and files are mostly used in the Tygron Geodesign Platform as a means to import dynamic overlay attributes. By default, attributes of an overlay, such as rain over time, are generated as a linear event. To incorporate a more dynamic flow of, for example, a dynamic breach area or dynamic period of rain, a custom option is available where an attribute array can be uploaded in CSV format.
It is important to note that such a CSV file containing a dynamic array, can only contain up to a maximum of 10.000 records/ timestamps, to avoid calculations becomming too long or complex.
Adding a dynamic rain array as CSV file to a rainfall overlay
An example of a simple dynamic rain array in seconds as CSV file (rain1.csv) would look like this:
Seconds; Rain(mm) 21600; 30 25200; 0 28800; 20 32400; 45 36000; 70
- Load or create a project in the editor
- Add a Rainfall Overlay
- Open the Rainfall Overlay Wizard
- Select in step 1 the Custom option for Rain over time and select Import
- Select Import new CSV on the newly opened panel
- Select the CSV file to import and select Open
- Select the time units
- Select the separator type
- Confirm the correct data is shown and select OK
- Now the rain event of the overlay is dynamic
Exporting a CSV file from the Tygron Geodesign Platform
It is also possible to export data from the Platform in CSV format, and specifically 2D vector data. The following elements of the platform support exportring geodata as a CSV file:
See also
Import CSV
- How to import a time sequence with a CSV
- 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)