[Haskell-cafe] Simple CSV parser?
Dmitri O.Kondratiev
dokondr at gmail.com
Fri Jun 17 10:08:28 CEST 2011
On Fri, Jun 17, 2011 at 2:37 AM, Henning Thielemann <
lemming at henning-thielemann.de> wrote:
>
> On Thu, 16 Jun 2011, Felipe Almeida Lessa wrote:
>
> [1] http://hackage.haskell.org/**package/bytestring-csv<http://hackage.haskell.org/package/bytestring-csv>
>> [2] http://hackage.haskell.org/**package/csv-enumerator<http://hackage.haskell.org/package/csv-enumerator>
>> [3] http://hackage.haskell.org/**package/spreadsheet<http://hackage.haskell.org/package/spreadsheet>
>> [4] http://hackage.haskell.org/**package/csv<http://hackage.haskell.org/package/csv>
>> [5] http://hackage.haskell.org/**package/ssv<http://hackage.haskell.org/package/ssv>
>>
>
> I have updated
> http://www.haskell.org/**haskellwiki/Spreadsheet<http://www.haskell.org/haskellwiki/Spreadsheet>
>
>
=== I am trying Data.Spreadseet.fromStringSimple , which is:
fromString :: Char<http://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char.html#t:Char>->
Char<http://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char.html#t:Char>->
String<http://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char.html#t:String>->
Exceptional<http://hackage.haskell.org/packages/archive/explicit-exception/0.1.6/doc/html/Control-Monad-Exception-Asynchronous.html#t:Exceptional>UserMessage
T<http://hackage.haskell.org/packages/archive/spreadsheet/0.1.1/doc/html/Data-Spreadsheet.html#t:T>
Source<http://hackage.haskell.org/packages/archive/spreadsheet/0.1.1/doc/html/src/Data-Spreadsheet.html#fromString>
fromString qm sep text parses text into a spreadsheet, using the quotation
character qm and the separator character sep.
fromStringSimple ::
Char<http://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char.html#t:Char>->
Char<http://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char.html#t:Char>->
String<http://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Char.html#t:String>->
T<http://hackage.haskell.org/packages/archive/spreadsheet/0.1.1/doc/html/Data-Spreadsheet.html#t:T>
=== 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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110617/6d51a41d/attachment.htm>
More information about the Haskell-Cafe
mailing list