-
Notifications
You must be signed in to change notification settings - Fork 1
/
transposetab.hs
32 lines (27 loc) · 933 Bytes
/
transposetab.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 : transposetab
-- Copyright : (c) Keith Sheppard 2009-2010
-- License : BSD3
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : portable
--
-- Transpose a tab-delimited 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 tabDelimitedFormat $ contents
tabText = formatTable tabDelimitedFormat table
putStr tabText
-- we were expecting a single file name arg
_ -> printSingleFileUsage