-
Notifications
You must be signed in to change notification settings - Fork 1
/
transposecsv.hs
32 lines (27 loc) · 907 Bytes
/
transposecsv.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-----------------------------------------------------------------------------
-- |
-- Module : transposecsv
-- Copyright : (c) Keith Sheppard 2009-2010
-- License : BSD3
-- Maintainer : keithshep@gmail.com
-- Stability : experimental
-- Portability : portable
--
-- Transpose the CSV file
--
-----------------------------------------------------------------------------
import Data.List
import System.Environment
import Database.TxtSushi.FlatFile
import Database.TxtSushi.IOUtil
main :: IO ()
main = do
args <- getArgs
case args of
[fileArg] -> do
contents <- getContentsFromFileOrStdin fileArg
let table = transpose . parseTable csvFormat $ contents
csvText = formatTable csvFormat table
putStr csvText
-- we were expecting a single file name arg
_ -> printSingleFileUsage