Opened 11 years ago
Last modified 9 years ago
#772 closed enhancement
inv_csv function not supported — at Version 10
Reported by: | Marcus Sen | Owned by: | Vlad Zamfir |
---|---|---|---|
Priority: | major | Milestone: | 9.2 |
Component: | manuals_and_examples | Version: | 9.0 |
Keywords: | Cc: | James Passmore, Peter Baumann | |
Complexity: | Medium |
Description (last modified by )
Implement an inv_csv
function for reading nD CSV files.
Not strictly for CSV, as the formatting doesn't matter much actually, so it's very flexible.
Numbers from the input file are read in order of appearance and stored without any reordering in rasdaman;
whitespace plus the following characters are ignored: '{', '}', ',', '"', '\'', '(', ')', '[', ']'
Mandatory extra parameters:
domain
- minterval, e.g.[1:5,0:10,2:3]
- the domain has to match the number of cells read from the input file
basetype
- array base type, e.g.long
,char
, etc.- struct types have to be specified fully, e.g.
struct { char red, char blue, char green }
- struct types have to be specified fully, e.g.
Example
A
is a 2x3 array of longs:
1,2,3,2,1,3
Inserting A
can be done with
insert into A values inv_csv($1, "domain=[0:1,0:2];basetype=long")
B
is an 1x2 array of RGB values
{1,2,3},{2,1,3}
Inserting B
can be done with
insert into B values inv_csv($1, "domain=[0:0,0:1];basetype=struct {char red, char blue, char green}")
B
could just as well be formatted like this with the same effect:
1 2 3 2 1 3
Change History (10)
comment:1 by , 11 years ago
Cc: | added |
---|---|
Component: | undecided → conversion |
comment:2 by , 11 years ago
Component: | conversion → manuals_and_examples |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Reassigning to Peter for fixing the manual.
comment:4 by , 11 years ago
Owner: | changed from | to
---|
Proposal
Implement an inv_csv
conversion function that will read a plaintext csv-like representation of an array.
Problem
How to encode the domain/type of the array in the plaintext file?
The bounding box can be encoded with parentheses or other markers, as is done in the csv
function. There is no option for representing the type however.
Solution
Encode domain/type with the extra params of inv_csv. This allows to get rid of the parentheses in the input file, and have just comma-separated values (proper csv encoding).
Rules for the csv encoding:
- single values are separated by comma
- composite values are wrapped in braces, within which single values are separated by commas
- white space is ignored
Extra params:
domain
- minterval, e.g.[1:5,0:10,2:3]
basetype
- array base type, e.g.RGBPixel
,long
,char
, etc.
Example
A
is a 2x3 array of longs:
1,2,3,2,1,3
Inserting A
can be done with
insert into A values inv_csv($1, "domain=[0:1,0:2];basetype=long")
B
is an 1x2 array of RGB values
{1,2,3},{2,1,3}
Inserting B
can be done with
insert into B values inv_csv($1, "domain=[0:0,0:1];basetype=RGBPixel")
Implementation
In source:conversion/csv.cc the convertFrom() function should be implemented. tiff.cc would provide a good example for the implementation.
Appropriate tests should be provided in source:systemtest/testcases_mandatory/test_conversion/test.sh
comment:5 by , 10 years ago
Component: | manuals_and_examples → conversion |
---|---|
Milestone: | → 9.1 |
comment:6 by , 9 years ago
Owner: | changed from | to
---|
comment:7 by , 9 years ago
Milestone: | 9.1 → 9.2 |
---|
comment:8 by , 9 years ago
Description: | modified (diff) |
---|
comment:9 by , 9 years ago
Description: | modified (diff) |
---|
comment:10 by , 9 years ago
Description: | modified (diff) |
---|---|
Type: | defect → enhancement |
inv_csv is a mistake in the QL guide.