
Hi, This time I am looking for a simple CSV parser that supports commas and quotes. I have no time now to learn Parsec, so I hope to find something simple and easy to use. Thanks!

Do any of the ones on hackage work for you? http://hackage.haskell.org/package/csv-0.1.2 http://hackage.haskell.org/package/bytestring-csv http://hackage.haskell.org/package/csv-enumerator (note: hackage supports search via google.... it works reasonably well) On Jun 16, 2011, at 5:21 PM, Dmitri O.Kondratiev wrote:
Hi, This time I am looking for a simple CSV parser that supports commas and quotes. I have no time now to learn Parsec, so I hope to find something simple and easy to use.
Thanks! _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Thu, 16 Jun 2011, Daniel Patterson wrote:
Do any of the ones on hackage work for you? http://hackage.haskell.org/package/csv-0.1.2
http://hackage.haskell.org/package/bytestring-csv
http://hackage.haskell.org/package/csv-enumerator
(note: hackage supports search via google.... it works reasonably well)
How could it miss my lovely package named "spreadsheet"? It provides a lazy parser.

That was my (lazy) fault. I saw the name and (faultily) assumed that it provided functionality on top of another CSV parser. On Jun 16, 2011, at 5:33 PM, Henning Thielemann wrote:
On Thu, 16 Jun 2011, Daniel Patterson wrote:
Do any of the ones on hackage work for you? http://hackage.haskell.org/package/csv-0.1.2 http://hackage.haskell.org/package/bytestring-csv http://hackage.haskell.org/package/csv-enumerator (note: hackage supports search via google.... it works reasonably well)
How could it miss my lovely package named "spreadsheet"? It provides a lazy parser.

On Fri, Jun 17, 2011 at 1:33 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote:
How could it miss my lovely package named "spreadsheet"? It provides a lazy parser.
Installing "spreadsheet": cabal install Resolving dependencies... cabal: cannot configure explicit-exception-0.1.6. It requires transformers ==0.2.* For the dependency on transformers ==0.2.* there are these packages: transformers-0.2.0.0, transformers-0.2.1.0 and transformers-0.2.2.0. However none of them are available. transformers-0.2.0.0 was excluded because spreadsheet-0.1 requires transformers ==0.0.* transformers-0.2.1.0 was excluded because spreadsheet-0.1 requires transformers ==0.0.* transformers-0.2.2.0 was excluded because spreadsheet-0.1 requires transformers ==0.0.* How to make cabal install all the dependencies? I couldn't find this in the docs at: http://www.haskell.org/haskellwiki/Cabal-Install

On Fri, 17 Jun 2011, Dmitri O.Kondratiev wrote:
How to make cabal install all the dependencies? I couldn't find this in the docs at: http://www.haskell.org/haskellwiki/Cabal-Install
Usually, 'cabal install' automatically installs all imported packages. But it will certainly not do, if a dependency problem cannot be solved by downloading packages. In your case it may be, that installed packages are compiled with respect to different versions of the same package, say 'transformers'. I found out, that you get more useful cabal messages if you force cabal-install to use a specific version of a package. Say, run $ ghc-pkg list transformers transformers-0.2.2.0 Then call $ cabal install spreadsheet --constraint=transformers==0.2.2.0 What does 'cabal' tell you?

On Thu, Jun 16, 2011 at 3:05 PM, Henning Thielemann
On Fri, 17 Jun 2011, Dmitri O.Kondratiev wrote:
How to make cabal install all the dependencies? I couldn't find this in the docs at: http://www.haskell.org/haskellwiki/Cabal-Install
Usually, 'cabal install' automatically installs all imported packages. But it will certainly not do, if a dependency problem cannot be solved by downloading packages. In your case it may be, that installed packages are compiled with respect to different versions of the same package, say 'transformers'.
I found out, that you get more useful cabal messages if you force cabal-install to use a specific version of a package.
Say, run $ ghc-pkg list transformers transformers-0.2.2.0
Then call $ cabal install spreadsheet --constraint=transformers==0.2.2.0
Nicer still, is to use cabal-dev: http://www.reddit.com/r/haskell/comments/f3ykj/psa_use_cabaldev_to_solve_dep... Jason

On Fri, Jun 17, 2011 at 2:05 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote:
On Fri, 17 Jun 2011, Dmitri O.Kondratiev wrote:
How to make cabal install all the dependencies? I couldn't find this in
the docs at: http://www.haskell.org/haskellwiki/Cabal-Install
Usually, 'cabal install' automatically installs all imported packages. But it will certainly not do, if a dependency problem cannot be solved by downloading packages. In your case it may be, that installed packages are compiled with respect to different versions of the same package, say 'transformers'.
I found out, that you get more useful cabal messages if you force cabal-install to use a specific version of a package.
Say, run $ ghc-pkg list transformers
transformers-0.2.2.0
Then call $ cabal install spreadsheet --constraint=transformers==0.2.2.0
What does 'cabal' tell you?
ghc-pkg list transformers /Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.3/package.conf.d: /Users/user/.ghc/i386-darwin-6.12.3/package.conf.d: transformers-0.2.2.0 cabal install spreadsheet --constraint=transformers==0.2.2.0 Resolving dependencies... cabal: cannot configure spreadsheet-0.1. It requires transformers ==0.0.* For the dependency on transformers ==0.0.* there are these packages: transformers-0.0.0.0 and transformers-0.0.1.0. However none of them are available. transformers-0.0.0.0 was excluded because of the top level dependency transformers ==0.2.2.0 transformers-0.0.1.0 was excluded because of the top level dependency transformers ==0.2.2.0 Compilation exited abnormally with code 1 at Fri Jun 17 02:12:30

On Fri, Jun 17, 2011 at 2:13 AM, Dmitri O.Kondratiev
On Fri, Jun 17, 2011 at 2:05 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote:
On Fri, 17 Jun 2011, Dmitri O.Kondratiev wrote:
How to make cabal install all the dependencies? I couldn't find this in
the docs at: http://www.haskell.org/haskellwiki/Cabal-Install
Usually, 'cabal install' automatically installs all imported packages. But it will certainly not do, if a dependency problem cannot be solved by downloading packages. In your case it may be, that installed packages are compiled with respect to different versions of the same package, say 'transformers'.
I found out, that you get more useful cabal messages if you force cabal-install to use a specific version of a package.
Say, run $ ghc-pkg list transformers
transformers-0.2.2.0
Then call $ cabal install spreadsheet --constraint=transformers==0.2.2.0
What does 'cabal' tell you?
ghc-pkg list transformers
/Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.3/package.conf.d:
/Users/user/.ghc/i386-darwin-6.12.3/package.conf.d:
transformers-0.2.2.0
cabal install spreadsheet --constraint=transformers==0.2.2.0 Resolving dependencies... cabal: cannot configure spreadsheet-0.1. It requires transformers ==0.0.* For the dependency on transformers ==0.0.* there are these packages: transformers-0.0.0.0 and transformers-0.0.1.0. However none of them are available. transformers-0.0.0.0 was excluded because of the top level dependency
transformers ==0.2.2.0 transformers-0.0.1.0 was excluded because of the top level dependency
transformers ==0.2.2.0
Compilation exited abnormally with code 1 at Fri Jun 17 02:12:30
I really have no choice, but install Data.Spreadsheet, because this is the only library that allows split a _single_ CSV string into chunks (which is exactly what I need). All other libs work with CSV files or provide a DSL to do such a simple thing!

On Fri, 17 Jun 2011, Dmitri O.Kondratiev wrote:
cabal install spreadsheet --constraint=transformers==0.2.2.0 Resolving dependencies... cabal: cannot configure spreadsheet-0.1. It requires transformers ==0.0.* For the dependency on transformers ==0.0.* there are these packages: transformers-0.0.0.0 and transformers-0.0.1.0. However none of them are available. transformers-0.0.0.0 was excluded because of the top level dependency transformers ==0.2.2.0 transformers-0.0.1.0 was excluded because of the top level dependency transformers ==0.2.2.0
I see. I had fixed the problem locally long time ago, but somehow missed upload to Hackage. Try the updated package, please.

On Fri, Jun 17, 2011 at 2:27 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote:
I see. I had fixed the problem locally long time ago, but somehow missed upload to Hackage. Try the updated package, please.
Ok great! Installed (with some warnings, see below), thank you! I'll try it tomorrow (now here is 2:34 am) on a file of about 4000 lines. Thanks! ==== Compilation started at Fri Jun 17 02:29:59 cabal install Resolving dependencies... Downloading explicit-exception-0.1.6... Configuring explicit-exception-0.1.6... Preprocessing library explicit-exception-0.1.6... Preprocessing executables for explicit-exception-0.1.6... Building explicit-exception-0.1.6... [1 of 9] Compiling Control.Monad.Label ( src/Control/Monad/Label.hs, dist/build/Control/Monad/Label.o ) [2 of 9] Compiling Control.Monad.Exception.Synchronous ( src/Control/Monad/Exception/Synchronous.hs, dist/build/Control/Monad/Exception/Synchronous.o ) [3 of 9] Compiling Control.Monad.Exception.Warning ( src/Control/Monad/Exception/Warning.hs, dist/build/Control/Monad/Exception/Warning.o ) [4 of 9] Compiling Control.Monad.Exception.Label ( src/Control/Monad/Exception/Label.hs, dist/build/Control/Monad/Exception/Label.o ) [5 of 9] Compiling System.IO.Straight ( src/System/IO/Straight.hs, dist/build/System/IO/Straight.o ) src/System/IO/Straight.hs:61:9: Warning: orphan instance: instance (MonadSIO m, ContainsIOException e) => MonadIO (ExceptionalT e m) [6 of 9] Compiling System.IO.Exception.File ( src/System/IO/Exception/File.hs, dist/build/System/IO/Exception/File.o ) [7 of 9] Compiling System.IO.Exception.BinaryFile ( src/System/IO/Exception/BinaryFile.hs, dist/build/System/IO/Exception/BinaryFile.o ) [8 of 9] Compiling Control.Monad.Exception.Asynchronous ( src/Control/Monad/Exception/Asynchronous.hs, dist/build/Control/Monad/Exception/Asynchronous.o ) [9 of 9] Compiling System.IO.Exception.TextFile ( src/System/IO/Exception/TextFile.hs, dist/build/System/IO/Exception/TextFile.o ) src/System/IO/Exception/TextFile.hs:8:0: Warning: In the use of `Async.manySynchronousT' (imported from Control.Monad.Exception.Asynchronous): Deprecated: "use manyMonoidT with appropriate Monad like LazyIO and result Monoid like Endo instead" Registering explicit-exception-0.1.6... Installing library in /Users/user/.cabal/lib/explicit-exception-0.1.6/ghc-6.12.3 Registering explicit-exception-0.1.6... Configuring spreadsheet-0.1.1... Preprocessing library spreadsheet-0.1.1... Building spreadsheet-0.1.1... [1 of 3] Compiling Data.Spreadsheet.CharSource ( src/Data/Spreadsheet/CharSource.hs, dist/build/Data/Spreadsheet/CharSource.o ) [2 of 3] Compiling Data.Spreadsheet.Parser ( src/Data/Spreadsheet/Parser.hs, dist/build/Data/Spreadsheet/Parser.o ) [3 of 3] Compiling Data.Spreadsheet ( src/Data/Spreadsheet.hs, dist/build/Data/Spreadsheet.o ) Registering spreadsheet-0.1.1... Installing library in /Users/user/.cabal/lib/spreadsheet-0.1.1/ghc-6.12.3 Registering spreadsheet-0.1.1... Compilation finished at Fri Jun 17 02:30:05

On Thu, Jun 16, 2011 at 6:21 PM, Dmitri O.Kondratiev
This time I am looking for a simple CSV parser that supports commas and quotes. I have no time now to learn Parsec, so I hope to find something simple and easy to use.
1. Go to http://hackage.haskell.org/packages/archive/pkg-list.html 2. Press Ctrl+F, look for "CSV". 3. Find many packages [1,2,3,4,5] 4. See which one suits better your needs. [1] http://hackage.haskell.org/package/bytestring-csv [2] http://hackage.haskell.org/package/csv-enumerator [3] http://hackage.haskell.org/package/spreadsheet [4] http://hackage.haskell.org/package/csv [5] http://hackage.haskell.org/package/ssv -- Felipe.

On Fri, Jun 17, 2011 at 1:27 AM, Felipe Almeida Lessa < felipe.lessa@gmail.com> wrote:
On Thu, Jun 16, 2011 at 6:21 PM, Dmitri O.Kondratiev
wrote: This time I am looking for a simple CSV parser that supports commas and quotes. I have no time now to learn Parsec, so I hope to find something simple and easy to use.
1. Go to http://hackage.haskell.org/packages/archive/pkg-list.html
2. Press Ctrl+F, look for "CSV".
3. Find many packages [1,2,3,4,5]
4. See which one suits better your needs.
[1] http://hackage.haskell.org/package/bytestring-csv [2] http://hackage.haskell.org/package/csv-enumerator [3] http://hackage.haskell.org/package/spreadsheet [4] http://hackage.haskell.org/package/csv [5] http://hackage.haskell.org/package/ssv
-- Felipe.
Now I know where and how to search, sorry for trivial questions ) Thanks!

On Thu, 16 Jun 2011, Felipe Almeida Lessa wrote:
[1] http://hackage.haskell.org/package/bytestring-csv [2] http://hackage.haskell.org/package/csv-enumerator [3] http://hackage.haskell.org/package/spreadsheet [4] http://hackage.haskell.org/package/csv [5] http://hackage.haskell.org/package/ssv
I have updated http://www.haskell.org/haskellwiki/Spreadsheet

On Fri, Jun 17, 2011 at 2:37 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote:
On Thu, 16 Jun 2011, Felipe Almeida Lessa wrote:
[1] http://hackage.haskell.org/**package/bytestring-csvhttp://hackage.haskell.org/package/bytestring-csv
[2] http://hackage.haskell.org/**package/csv-enumeratorhttp://hackage.haskell.org/package/csv-enumerator [3] http://hackage.haskell.org/**package/spreadsheethttp://hackage.haskell.org/package/spreadsheet [4] http://hackage.haskell.org/**package/csvhttp://hackage.haskell.org/package/csv [5] http://hackage.haskell.org/**package/ssvhttp://hackage.haskell.org/package/ssv
I have updated http://www.haskell.org/**haskellwiki/Spreadsheethttp://www.haskell.org/haskellwiki/Spreadsheet
=== I am trying Data.Spreadseet.fromStringSimple , which is: fromString :: Charhttp://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char....-> Charhttp://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char....-> Stringhttp://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char....-> Exceptionalhttp://hackage.haskell.org/packages/archive/explicit-exception/0.1.6/doc/htm...UserMessage Thttp://hackage.haskell.org/packages/archive/spreadsheet/0.1.1/doc/html/Data-... Sourcehttp://hackage.haskell.org/packages/archive/spreadsheet/0.1.1/doc/html/src/D... fromString qm sep text parses text into a spreadsheet, using the quotation character qm and the separator character sep. fromStringSimple :: Charhttp://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char....-> Charhttp://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char....-> Stringhttp://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char....-> Thttp://hackage.haskell.org/packages/archive/spreadsheet/0.1.1/doc/html/Data-... === Here is my test where quotation mark is a quote (") and separator is a comma (,): t1 = fromStringSimple '"' ',' tMsg tMsg = "REP-RPB1.domain1.systemhost.net,Microsoft.Windows.Computer: REP-RPB1.domain1.systemhost.net,- System Uptime > 30 Days,UIGeneratedMonitor3a4ca3359ec34015bee55fd7942836d8,2,Custom,10/17/2009 8:48:38 AM" === As a result I get: [["*** Exception: dequoteSimple: string does not end with a quotation mark === Question: In this particular line I have no quotation mark, but in other lines I may have quoted text fields, separated by commas (,) and also with commas *iside* quoted fields . What parameters should I pass to 'fromStringSimple' so it worked in both cases: 1) for lines with quotation marks and 2) for lines without quotation marks? Thanks!
participants (5)
-
Daniel Patterson
-
Dmitri O.Kondratiev
-
Felipe Almeida Lessa
-
Henning Thielemann
-
Jason Dagit