[Haskell-cafe] Data import from octave / text file
Lars Viklund
zao at acc.umu.se
Wed Jun 15 13:35:37 CEST 2011
On Wed, Jun 15, 2011 at 04:13:49AM -0700, kaffeepause73 wrote:
> The folloing file log.txt contains three signal traces in the three columns
> (time, signal 1, signal 2)
>
> 0 30 9
> 0.1 30 9
> 0.2 30 9
>
> let m = read text :: [[Double]]
>
> SecondLot
> signalImport: Prelude.read: no parse
Instances of Read tends to expect the format that Show would output. In
the case of lists, it's [elem1,elem2,elem3].
You can either modify your exporter to output values in the format that
read expects, or you could use a combination of the functions 'lines',
'words' and 'read' to split the input into a list of lines, split each
line into a list of words, and finally use read to go from word to
Double.
--
Lars Viklund | zao at acc.umu.se
More information about the Haskell-Cafe
mailing list