1module TutorialD.Interpreter.Import.CSV where
2import TutorialD.Interpreter.Import.Base
5import ProjectM36.Relation.Parse.CSV
6import qualified Data.ByteString.Lazy as BS
7import qualified Data.Text as T
8import Text.Megaparsec.Text
9import TutorialD.Interpreter.Base
10import Control.Exception
12importCSVRelation :: RelVarName -> Attributes -> FilePath -> IO (Either RelationalError DatabaseContextExpr)
13importCSVRelation relVarName attrs pathIn = do
14 --TODO: handle filesystem errors
15 csvData <- try (BS.readFile pathIn) :: IO (Either IOError BS.ByteString)
17 Left err -> return $ Left (ImportError $ T.pack (show err))
18 Right csvData' -> case csvAsRelation csvData' attrs of
19 Left err -> return $ Left (ParseError $ T.pack (show err))
20 Right csvRel -> return $ Right (Insert relVarName (ExistingRelation csvRel))
22importCSVP :: Parser RelVarDataImportOperator
27 relVarName <- identifier
28 return $ RelVarDataImportOperator relVarName (T.unpack path) importCSVRelation
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list