[Haskell-cafe] Data import from octave / text file

Philipp Schuster pandragon at gmx.net
Wed Jun 15 15:27:16 CEST 2011


Hi,

try Numeric.Container.loadMatrix.

Regards,
Philipp


On 15.06.2011 14:59, kaffeepause73 wrote:
> 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 = takeColumns 1 a
>       putStrLn (show t)
>
>       putStrLn "Finish"
>
>
>
> --
> View this message in context: http://haskell.1045720.n5.nabble.com/Data-import-from-octave-text-file-tp4490870p4491136.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.





More information about the Haskell-Cafe mailing list