packages feed

ods2csv 0.1.0.1 → 0.1.0.2

raw patch · 2 files changed

+29/−21 lines, 2 files

Files

ods2csv.cabal view
@@ -1,5 +1,5 @@ Name:                ods2csv-Version:             0.1.0.1+Version:             0.1.0.2 Synopsis:            Convert Open Document Spreadsheet ODS to CSV Description:   Usually you would convert ODS to CSV via @libreoffice --headless@@@ -48,7 +48,7 @@ Cabal-Version:       >=1.10  Source-Repository this-  Tag:         0.1.0.1+  Tag:         0.1.0.2   Type:        darcs   Location:    https://hub.darcs.net/thielema/ods2csv @@ -63,7 +63,7 @@     tagchup >=0.4 && <0.5,     xml-basic >=0.1.1 && <0.2,     shell-utility >=0.1 && <0.2,-    optparse-applicative >=0.11 && <0.19,+    optparse-applicative >=0.11 && <0.20,     utf8-string >=1.0.2 && <1.1,     bytestring >=0.10 && <0.13,     non-empty >=0.3.4 && <0.4,
src/Main.hs view
@@ -72,13 +72,6 @@    guard $ NameC.match "table:table" foundName    Attr.lookupLit "table:name" attrs -maybeCell :: Tag.T Name.T String -> Maybe Int-maybeCell tag = do-   (foundName, attrs) <- Tag.maybeOpen tag-   guard $ NameC.match "table:table-cell" foundName-   case fmap reads $ Attr.lookupLit "table:number-columns-repeated" attrs of-      Just [(n,_)] -> return n-      _ -> return 1  {- <config:config-item-map-entry config:name="BlaBlaBla">@@ -111,21 +104,36 @@          <|>          toMaybe (TagMatch.closeNameLit "text:s" tag) "") +flattenRepeatedCell :: Int -> [Tag.T Name.T String] -> [String]+flattenRepeatedCell n =+   replicate n+   .+   flattenText+   .+   takeWhile (not . TagMatch.closeNameLit "text:p")+   .+   drop 1+   .+   dropWhile (not . TagMatch.openNameLit "text:p")++maybeCell :: Tag.T Name.T String -> Maybe ([Tag.T Name.T String] -> [String])+maybeCell tag = do+   (foundName, attrs) <- Tag.maybeOpen tag+   toMaybe (NameC.match "table:covered-table-cell" foundName) (const [""])+      <|>+      toMaybe+         (NameC.match "table:table-cell" foundName)+         (flattenRepeatedCell $+            let repAttr = "table:number-columns-repeated" in+            case fmap reads $ Attr.lookupLit repAttr attrs of+               Just [(k,_)] -> k+               _ -> 1)+ extractTablesContents :: [Tag.T Name.T String] -> [(String, [[String]])] extractTablesContents =    map (mapSnd (          map-            (concatMap-               (uncurry $ \n ->-                  replicate n-                  .-                  flattenText-                  .-                  takeWhile (not . TagMatch.closeNameLit "text:p")-                  .-                  drop 1-                  .-                  dropWhile (not . TagMatch.openNameLit "text:p"))+            (concatMap (uncurry ($))              .              snd              .