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