
Hey guys, thanks for the very quick help. The code works and looks like: (any tips regards speed and memory usage ?) import System.IO import Data.Array import Data.Packed.Matrix parse :: String -> [[Double]] -- expects plainer syntax parse = map (map read . words) . lines main = do -- read and show plain text text <- readFile "./log.txt" putStrLn text -- read and show parsed list of lists putStrLn "parsed list of lists" let m = parse text putStrLn (show m) -- convert to matrix and show let a = fromLists m putStrLn (show a) -- cuts out first row to get signal let t = takerows 1 m putStrLn (show t) putStrLn "Finish" kaffeepause73 wrote:
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-tp449... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.