-
Notifications
You must be signed in to change notification settings - Fork 1
/
csvtotab.hs
31 lines (26 loc) · 908 Bytes
/
csvtotab.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
-----------------------------------------------------------------------------
-- |
-- Module : csvtotab
-- Copyright : (c) Keith Sheppard 2009-2010
-- License : BSD3
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : portable
--
-- Converts CSV into tab-delimited
--
-----------------------------------------------------------------------------
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 = parseTable csvFormat contents
tabDelimitedText = formatTable tabDelimitedFormat table
putStr tabDelimitedText
-- we were expecting a single file name arg
_ -> printSingleFileUsage