
Hi, I need to parse a file in this format: float float float float float float Each row has 3-columns of floating procision number divided by white space. The number of lines is undefined. I use (lines (readFile "...")) to read the file. Thnks. Matej 'Yin' Gagyi

I need to parse a file in this format: float float float float float float Each row has 3-columns of floating procision number divided by white space. The number of lines is undefined. I use (lines (readFile "...")) to read the file.
Text.ParserCombinators.Parsec sounds perfect, no?

On Wed, 20 Jul 2005, Jake Luck wrote:
I need to parse a file in this format: float float float float float float Each row has 3-columns of floating procision number divided by white space. The number of lines is undefined. I use (lines (readFile "...")) to read the file.
Text.ParserCombinators.Parsec sounds perfect, no?
That's certainly overkill since 'lines', 'words', 'read' will suffice.

On 7/20/05, yin
Hi,
I need to parse a file in this format: float float float float float float Each row has 3-columns of floating procision number divided by white space. The number of lines is undefined. I use (lines (readFile "...")) to read the file.
Off the top of my head: readVecs :: String -> IO [Vector3 GLfloat] readVecs f = do str <- readFile f let mkVec [x,y,z] = Vector3 x y z return $ map (mkVec . read . words) $ lines str Of course this won't exactly fail gracefully if the file is corrupt or anything like that... /S -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862
participants (4)
-
Henning Thielemann
-
Jake Luck
-
Sebastian Sylvan
-
yin