read :: String ->  [[Double]] can't read this format. It expects 
"[[0,30,9],[0.1,30,9],...]"

use this code
let m = map f text :: [[Double]]
    f a = map g $ lines a
    g a = map read $ words a


15.06.2011 15:13, kaffeepause73 пишет:
Dear all,

I want to read numeric data in vector / matrix format generated by octave.
As I haven't seen any octave specific libraries yet (only matlab), I'm
tyrying the way via ascii - file.

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
  0.3 30 9
  0.4 30 9
  0.5 30 9
  0.6000000000000001 30 9
  0.7000000000000001 30 9
  0.8 30 9
  0.9 30 9
  1 30 9

I got the following bit of code compiled with ghc:

import System.IO

main = do
      text<- readFile "./log.txt"
      putStrLn text

      putStrLn "SecondLot"

      let m = read text :: [[Double]]
      putStrLn (show m)

      putStrLn "Finish"

Reading text works, but not reading text into m. The Output:

  0 30 9
  0.1 30 9
  0.2 30 9
  0.3 30 9
  0.4 30 9
  0.5 30 9
  0.6000000000000001 30 9
  0.7000000000000001 30 9
  0.8 30 9
  0.9 30 9
  1 30 9

SecondLot
signalImport: Prelude.read: no parse

Any suggestions ? - Thanks in advance.

--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Data-import-from-octave-text-file-tp4490870p4490870.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to