You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Toivo Adams <to...@gmail.com> on 2016/05/06 20:03:22 UTC

CSV: Should whitespace allowed before and after type string?

Hi,

CSV first line describes column names and types.
Should whitespace allowed before and after type string?

Input:
ID:int,AMOUNT1:float,AMOUNT2:float,AMOUNT3:float
008, 10.05, 15.45, 89.99
100, 20.25, 25.25, 45.25
105, 20.05, 25.05, 45.05
200, 34.05, 25.05, 75.05

Works without problems.

But
ID:int,AMOUNT1: float,AMOUNT2:float,AMOUNT3:float
008, 10.05, 15.45, 89.99
100, 20.25, 25.25, 45.25
105, 20.05, 25.05, 45.05
200, 34.05, 25.05, 75.05

fails

WARNING: Found unknown type: float in first line: for column: AMOUNT1. Will
assume the type of column is string

Simple trim in CsvEnumerator.deduceRowType
    typeString = typeString.trim();
fixes problem.

Should I create JIRA issue?

Thanks
Toivo

Re: CSV: Should whitespace allowed before and after type string?

Posted by Julian Hyde <jh...@apache.org>.
Using the “be liberal in what you accept” principle, yes.

Although this would be low priority for me, so you should only file a JIRA if you plan to attach a PR to it… :)

The CSV adapter was originally written for tutorial purposes. The way to make it real would be to find a spec for what is allowed in CSV format* and go implement it.

Julian

* unfortunately there are several

> On May 6, 2016, at 1:08 PM, Josh Elser <jo...@gmail.com> wrote:
> 
> Seems reasonable to me to strip() leading and trailing space around the header line...
> 
> Toivo Adams wrote:
>> Hi,
>> 
>> CSV first line describes column names and types.
>> Should whitespace allowed before and after type string?
>> 
>> Input:
>> ID:int,AMOUNT1:float,AMOUNT2:float,AMOUNT3:float
>> 008, 10.05, 15.45, 89.99
>> 100, 20.25, 25.25, 45.25
>> 105, 20.05, 25.05, 45.05
>> 200, 34.05, 25.05, 75.05
>> 
>> Works without problems.
>> 
>> But
>> ID:int,AMOUNT1: float,AMOUNT2:float,AMOUNT3:float
>> 008, 10.05, 15.45, 89.99
>> 100, 20.25, 25.25, 45.25
>> 105, 20.05, 25.05, 45.05
>> 200, 34.05, 25.05, 75.05
>> 
>> fails
>> 
>> WARNING: Found unknown type: float in first line: for column: AMOUNT1. Will
>> assume the type of column is string
>> 
>> Simple trim in CsvEnumerator.deduceRowType
>>     typeString = typeString.trim();
>> fixes problem.
>> 
>> Should I create JIRA issue?
>> 
>> Thanks
>> Toivo
>> 


Re: CSV: Should whitespace allowed before and after type string?

Posted by Josh Elser <jo...@gmail.com>.
Seems reasonable to me to strip() leading and trailing space around the 
header line...

Toivo Adams wrote:
> Hi,
>
> CSV first line describes column names and types.
> Should whitespace allowed before and after type string?
>
> Input:
> ID:int,AMOUNT1:float,AMOUNT2:float,AMOUNT3:float
> 008, 10.05, 15.45, 89.99
> 100, 20.25, 25.25, 45.25
> 105, 20.05, 25.05, 45.05
> 200, 34.05, 25.05, 75.05
>
> Works without problems.
>
> But
> ID:int,AMOUNT1: float,AMOUNT2:float,AMOUNT3:float
> 008, 10.05, 15.45, 89.99
> 100, 20.25, 25.25, 45.25
> 105, 20.05, 25.05, 45.05
> 200, 34.05, 25.05, 75.05
>
> fails
>
> WARNING: Found unknown type: float in first line: for column: AMOUNT1. Will
> assume the type of column is string
>
> Simple trim in CsvEnumerator.deduceRowType
>      typeString = typeString.trim();
> fixes problem.
>
> Should I create JIRA issue?
>
> Thanks
> Toivo
>