O'Reilly logo
  • Johan Hidding thinks this is interesting:

applyToColumnInCSV :: ([String] -> b) -> CSV -> String -> Either String b applyToColumnInCSV func csv column = either Left Right . func . elements columnIndex where columnIndex = getColumnInCSV csv column nfieldsInFile = length $ head csv records = tail $ filter (\record -> nfieldsInFile == length record) csv elements ci = map (\record -> genericIndex record ci) recor

From

Cover of Learning Haskell Data Analysis

Note

This function is highly unreadable. I ended up using fmap here