bugGNU Octave - Bugs: bug #55828, [octave forge] (io) csv2cell...

 
 

bug #55828: [octave forge] (io) csv2cell doesn't recognize some numeric input

Submitter:  A.R. Burgers <arb>
Submitted:  Mon 04 Mar 2019 07:58:30 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Need Info Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 04 Mar 2019 08:56:34 PM UTC, comment #1: 

I can confirm the behavior.
I can also following the logic that the field containing 3.0 would be expected to be read as a double value.
But IMO there's also something to say for treating fields containing non-numeric chars (incl. +-.E) as text.

How does other csv reading software treat numbers enclosed in spaces in data fields?

If I read the file with LibreOffice I get some import scheme dialog; entering just a comma as separator and then saving the resulting spreadsheet as an .ods file, I get the exact same results as with csv2cell:

>> [~, ~, d] = odsread ('bug55828.ods')
d =
{
  [1,1] = a
  [2,1] = str_a
  [1,2] =        b
  [2,2] =  3.0
  [1,3] =    c
  [2,3] =  18
}
>> cellfun (@class, d, "uni", 0)
ans =
{
  [1,1] = char
  [2,1] = char
  [1,2] = char
  [2,2] = char
  [1,3] = char
  [2,3] = double
}


But reading the file with Excel 2013 and processing the result with the Data | Text to Columns option it does give 3.0 as a double.

Matlab r2019a's importdata also reads the " 3.0 " field as a double value.

Furthermore csv2cell reads the following file:

 1 , 2 , 3
4, 5, 6


as all double values.

Just wondering if there's a formal rule or a convention as to spaces in number fields in .csv files (apart from core dev Rik's "principle of least surprise").

Until that is clear I'm tending to just postpone treatment. I'll gladly conform to a common opinion.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 04 Mar 2019 07:58:30 PM UTC, original submission:  

csv2cell seems to handle space after the number, between number and separator incorrectly.

Save the next 2 lines as file space.csv:


a,       b,   c
str_a, 3.0 , 18


read space.csv with the following script:


pkg load io;
ver = version
hg_id = __octave_config_info__.hg_id
pkg list io
data = csv2cell('space.csv', ',');
cellfun(@isnumeric, data)


The output is this (18 recognized as numeric, 3.0 not).
If I remove the space between 3.0 and "," 3.0 is recognized as a number.


ver = 5.1.1
hg_id = e07ea25d58f5+
Package Name  | Version | Installation directory
--------------+---------+-----------------------
          io *|  2.4.12 | /home/dusk/aburgers/octave-5.1/io-2.4.12
ans =
  0  0  0
  0  0  1


A.R. Burgers <arb>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by arb (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-05 mtmiller StatusNone Need Info
        Releaseother dev
        Summary[octave-forge] (io) csv2cell doesn't recognize some numeric input [octave forge] (io) csv2cell doesn't recognize some numeric input
    2019-03-04 mtmiller Summary[octave-forge](io) csv2cell doesn't recognize some numeric input [octave-forge] (io) csv2cell doesn't recognize some numeric input
    2019-03-04 philipnienhuis Release5.1.0 other
        Summaryio csv2cell doesn't recognize some numeric input [octave-forge](io) csv2cell doesn't recognize some numeric input

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code