[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: data cut-and-paste on Octave commandline

From: Tommy McCann
Subject: Re: data cut-and-paste on Octave commandline
Date: Tue, 16 Jul 2019 12:15:53 -0700

I'm not sure what format you are pulling in but if your tabular data can be read as a text file try this. 
x = textread('new.txt','%s','delimiter','\t')
x =
  [1,1] = some data
  [2,1] = 2,3,4,5,6
  [3,1] = other data

new.txt was just a single line of text in notepad "some data (TAB) 2,3,4,5,6 (TAB) other data"

You can then use textscan on individual cells to further  deliminate your data. 
y = textscan(x{2}, '%s', 'delimiter',','); y = y{1}
y =
  [1,1] = 2
  [2,1] = 3
  [3,1] = 4
  [4,1] = 5
  [5,1] = 6

then store it in another format (like double)
for istep = 1:length(y) ynum(istep) = str2double(y{istep}); endfor

However, it's computationally heavy to reformat your data line by line like in a for loop so if you have to do a lot of data I would recommend using textread and textscan to deliminate your headers search your headers for the row and columns that you want to analyze then use dlmread to pull in the numerical data. 

On Fri, Jul 12, 2019 at 10:38 AM Mike Miller <address@hidden> wrote:
On Fri, Jul 12, 2019 at 13:19:37 -0400, Przemek Klosowski wrote:
> Often I'd like to process some tabular data from other apps (browser or
> spreadsheet). It's easy enough to mark the entire table, but the multiple
> numbers on each row often seem to be delimited by tabs. When this is dropped
> into Octave command line after the opening stanza of the form 'myvar=[' ,
> the tabs are eaten by readline, and the individual numbers run together.
> With spreadsheet, I usually can cut and paste individual columns one-by-one,
> but this doesn't work for tabular data from other sources.
> Is there  a better way to feed data to Octave?
> If not, is there a way to temporarily turn off/disable readline processing?

Yes, you are looking for the readline option "enable-bracketed-paste".

    set enable-bracketed-paste on

to your ~/.inputrc and it should be taken care of automatically if you
are using any common terminal emulator that supports this feature.

Unfortunately, the Octave GUI terminal does *not* currently support
bracketed paste, so if you enable this option and use the GUI, you will
see a bunch of error messages about unrecognized escape sequences.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]