File: Frame.hs

package info (click to toggle)
bali-phy 4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,392 kB
  • sloc: cpp: 120,442; xml: 13,966; haskell: 9,975; python: 2,936; yacc: 1,328; perl: 1,169; lex: 912; sh: 343; makefile: 26
file content (15 lines) | stat: -rw-r--r-- 436 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Data.Frame ( csv_to_frame, readTable, ($$) )
    where

import qualified Data.Map as Map
import Data.CSV

-- This gives the csv file as a list of rows
csv_to_frame :: [ [ String ] ] -> Map.Map String [String]

csv_to_frame (header:rows) = Map.fromList [(field_name, map (!!i) rows) | (i,field_name) <- zip [0..] header]

readTable filename = csv_to_frame `liftM` read_csv filename

frame $$ field = map read (frame Map.! field)