Hi guys,
I'm parsing a text file which look like this:
114.474998474121 15.7440004348755 25.806999206543 -873 172 182 188
114.46199798584 15.7419996261597 25.8799991607666 -1396 180 192 205
And wish it can read as like this:
[[114.475,15.744,25.807,-873.0,172.0,182.0,188.0],
[114.462,15.742,25.88,-1396.0,180.0,192.0,205.0]]
Currently my code for this text parsing doesn't give that. Here is my code:
main = do
text <- readFile "mytext.txt"
let
pcVal = map read (words text) :: [Float]
print pcVal
return ()
This code parsed all the text as a single list like this:
[114.475,15.744,25.807,-873.0,172.0,182.0,188.0,
114.462,15.742,25.88,-1396.0,180.0,192.0,205.0]
I couldn't find how to take the whole single line (in text file) as a list, and the second line as another list till end of the file. Appreciate if somebody have experience in this. Thanks.