bugGNU Octave - Bugs: bug #58295, add boolean strings support to...

 
 

bug #58295: add boolean strings support to importdata()

Submitter:  Fabio <efferre79>
Submitted:  Sat 02 May 2020 06:24:54 PM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  3 - Low Item Group:  Feature Request
Status:  Wont Fix Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 23 May 2020 04:27:48 PM UTC, comment #3: 

Marking as Won't Fix.  This has easy enough workarounds outside of Octave that would then mean importdata could stay Matlab-compatible.

As an example, this one-line Perl script will convert True/False to 1/0.


perl -i.bak -pe 's/true/1/ig; s/false/0/ig;' FILENAME


Alternatively, search&replace in a text editor.

Rik <rik5>
Group administrator
Wed 06 May 2020 09:24:26 PM UTC, comment #2: 

Ok Mike, I understand your position. IMHO I imagine that octave at a certain point can not be longer 100% compatible with Matlab but could start offering extra functionalities :-)

Moreover do you think that returning empty strings in output.textdata is fine or shall I prepare a specific patch for that in a new bug?

Fabio <efferre79>
Wed 06 May 2020 08:49:18 PM UTC, comment #1: 

I don't use these I/O functions much, so take with a grain of salt, but I would think adding this feature, even as an option, would risk breaking Matlab compatibility. It's probably better to keep the importdata function as it is, dumb and only able to process numeric fields, returning all non-numeric text in textdata. For more capable file processing, it's probably better to use other functions or preprocess the file before reading it into Octave.

Mike Miller <mtmiller>
Group Member
Sat 02 May 2020 06:24:54 PM UTC, original submission:  

I am using logging files where among numbers there are also boolean values which are written as a text string "true" or "false". Currently importdata() treats those values as NA.

I have added a few lines to importdata() to convert the boolean strings into 0/1 integers. Do you like the idea? This of course is an extra functionality not event present in Matlab, maybe we can add an extra option argument to enable the possibility. What do you think?

Here is what happens currently:


octave:1> importdata('test.log',"\t")
ans =

  scalar structure containing the fields:

    data =

        14    56    NA   656     1    NA
         1    NA     0    21     0     6
         5     5    NA    NA     5     5

    textdata =
    {
      [1,1] = header
      [2,1] = header2
      [3,1] = col1              col3
      [4,1] = row1
      [5,1] =
      [6,1] = row2
      [7,1] = True
      [8,1] = row3
      [9,1] = False
      [10,1] =
    }


while this is the result with the proposed patch:


octave:1> importdata('test.log',"\t")
ans =

  scalar structure containing the fields:

    data =

        14    56    NA   656     1    NA
         1     1     0    21     0     6
         5     5     0    NA     5     5

    textdata =
    {
      [1,1] = header
      [2,1] = header2
      [3,1] = col1              col3
      [4,1] = row1
      [5,1] =
      [6,1] = row2
      [7,1] = row3
      [8,1] =
    }


The patch is still incomplete because it misses BITS too

Moreover I have also noticed that missing fields are correctly converted to NA but they produce empty strings in textdata, they could be removed too because meaningless.

Fabio <efferre79>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #48991:  test.log added by efferre79 (85B - text/x-log)
file #48992:  importdata.m.patch added by efferre79 (709B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by efferre79 (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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-05-23 rik5 StatusNone Wont Fix
        Open/ClosedOpen Closed
    2020-05-06 mtmiller Severity3 - Normal 1 - Wish
        Priority5 - Normal 3 - Low
    2020-05-06 mmuetzel Release5.2.0 dev
        Summaryadd boolean strings support to impordata() add boolean strings support to importdata()
    2020-05-02 efferre79 Attached File- Added test.log, #48991
        Attached File- Added importdata.m.patch, #48992

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code