Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Przemyslaw Kaminski
haskell-gargantext
Commits
4b09273b
Commit
4b09273b
authored
Oct 12, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[upload zip] some more work on zipfile parsing
parent
12c2beae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
New.hs
src/Gargantext/API/Node/Corpus/New.hs
+1
-1
Parsers.hs
src/Gargantext/Core/Text/Corpus/Parsers.hs
+6
-2
No files found.
src/Gargantext/API/Node/Corpus/New.hs
View file @
4b09273b
...
...
@@ -264,7 +264,7 @@ addToCorpusWithForm user cid (NewWithForm ft d l _n) logStatus jobLog = do
-- TODO granularity of the logStatus
let
data
'
=
case
ft
of
ZIP
->
case
BSB64
.
decode
$
TE
.
encodeUtf8
d
of
Left
err
->
panic
$
T
.
pack
"[addToCorpusWithForm] error decoding base64
"
err
Left
err
->
panic
$
T
.
pack
"[addToCorpusWithForm] error decoding base64
: "
<>
T
.
pack
err
Right
decoded
->
decoded
_
->
cs
d
eDocs
<-
liftBase
$
parse
data
'
...
...
src/Gargantext/Core/Text/Corpus/Parsers.hs
View file @
4b09273b
...
...
@@ -25,7 +25,8 @@ module Gargantext.Core.Text.Corpus.Parsers (FileFormat(..), clean, parseFile, cl
import
"zip"
Codec.Archive.Zip
(
withArchive
,
getEntry
,
getEntries
)
import
Control.Concurrent.Async
as
CCA
(
mapConcurrently
)
import
Control.Monad
(
join
)
import
Control.Monad
(
join
,
sequence
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Attoparsec.ByteString
(
parseOnly
,
Parser
)
import
Data.Either
(
Either
(
..
))
import
Data.Either.Extra
(
partitionEithers
)
...
...
@@ -100,7 +101,10 @@ parseFormat ZIP bs = do
path
<-
emptySystemTempFile
"parsed.zip"
DB
.
writeFile
path
bs
parsedZip
<-
withArchive
path
$
do
DM
.
keys
<$>
getEntries
files
<-
DM
.
keys
<$>
getEntries
filesContents
<-
mapM
getEntry
files
ddocs
<-
liftIO
$
mapM
(
parseFormat
CsvGargV3
)
filesContents
pure
$
sequence
ddocs
pure
$
Left
$
"Not implemented for ZIP, parsedZip"
<>
show
parsedZip
parseFormat
_
_
=
undefined
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment