Comma-Separated Values (Simple)
container.array.comma_separatedSimple list of comma-separated values (not JSON array, plain CSV). Example: "apple,banana,cherry"
Worked samples
DuckDB 1.5.5 · finetype 0.6.64
| Value | As VARCHAR | parts |
|---|---|---|
| apple,banana,cherry | apple,banana,cherry | ['apple', 'banana', 'cherry'] |
| 1,2,3,4,5 | 1,2,3,4,5 | ['1', '2', '3', '4', '5'] |
| red,green,blue | red,green,blue | ['red', 'green', 'blue'] |
Shape
^[^,]+(,[^,]+)*$| Value | Length | Shape |
|---|---|---|
| apple,banana,cherry | 19 | matches |
| 1,2,3,4,5 | 9 | matches |
| red,green,blue | 14 | matches |
Told apart
3 of the 3 other array types accept every one of these samples on shape alone.
- Pipe-Separated Valuesmatches them by pattern
- Semicolon-Separated Valuesmatches them by pattern
- Whitespace-Separated Valuesmatches them by pattern
Going the other way, this type's own rule accepts 2 of 2 samples of Pipe-Separated Values, 2 of 2 samples of Semicolon-Separated Values and 3 of 3 samples of Whitespace-Separated Values.
Background
Origin
FineType defines container.array.comma_separated itself, as a simple list of comma-separated values that is not a JSON array.[1] FineType's label definition gives apple,banana,cherry as its example value.[1] FineType's label definition decomposes the value with STRING_SPLIT on a comma.[1]
The Frictionless Table Schema defines a list type whose lexical form is a string of values separated by a delimiter, which is a comma by default.[2] Table Schema says its list type is directly modelled on the concept of SQL typed collections.[2]
The HTML Standard defines a set of comma-separated tokens as a string of zero or more tokens, each separated from the next by a single comma.[3] The HTML Standard counts the string " a ,b,,d d " as four tokens, one of which is the empty string.[3] The HTML Standard says leading and trailing whitespace around each comma-separated token does not count as part of the token.[3]
Use
RFC 4180 says that CSV fields containing commas should be enclosed in double quotes.[4] When a comma-separated list sits inside one field of a CSV file, read the file with a proper CSV parser first and split the field only afterwards. (Meridian's view) Before splitting, look for items that might themselves contain a comma, such as numbers written with thousands separators or names written surname first. (Meridian's view)
DuckDB's string_split(string, separator) function splits a string along the separator.[5] DuckDB lists string_to_array as an alias for string_split.[5] Frictionless Table Schema lets a list field declare an itemType, and the item type defaults to string when none is given.[2] Treat every item as text until you have split the list, then decide the element type from the items themselves. (Meridian's view) Trim whitespace from each item after splitting, and decide whether an empty item means a missing value or a mistake. (Meridian's view)
Sources
- [1]finetype/labels/definitions_container.yaml at main · meridian-online/finetype · GitHubFineType
- [2]Table Schema | Data Package Standardstandard
- [3]HTML Standardstandard
- [4]Common Format and MIME Type for Comma-Separated Values (CSV) Filesstandard
- [5]Text Functions – DuckDBdocumentation
Detection notes
v1 migration: New for v2. Simple comma-separated list (not JSON). Decompose splits on comma. Recursive inference samples to determine element type.
Use it
$ finetype infer -i "apple,banana,cherry" --mode column
→ container.array.comma_separated
SELECT ft_infer('apple,banana,cherry');
-- → 'container.array.comma_separated'CAST({col} AS VARCHAR)Schema
https://meridian.online/schemas/container.array.comma_separated · Frictionless type list
finetype taxonomy container.array.comma_separated -o json-schema