Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 8c64a593ea3f906f1aadde2e298f1490 > files > 11

ghc-csv-devel-0.1.2-11.fc16.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Text.CSV</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Text-CSV.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Text-CSV.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">csv-0.1.2: CSV loader and dumper</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>ghc </td></tr><tr><th>Stability</th><td>provisional </td></tr><tr><th>Maintainer</th><td>Jaap Weel &lt;weel at ugcs dot caltech dot edu&gt; </td></tr></table><p class="caption">Text.CSV</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This module parses and dumps documents that are formatted more or
   less according to RFC 4180, &quot;Common Format and MIME Type for
   Comma-Separated Values (CSV) Files&quot;,
   <a href="http://www.rfc-editor.org/rfc/rfc4180.txt">http://www.rfc-editor.org/rfc/rfc4180.txt</a>.
</p><p>There are some issues with this RFC. I will describe what these
   issues are and how I deal with them.
</p><p>First, the RFC prescribes CRLF standard network line breaks, but
   you are likely to run across CSV files with other line endings, so
   we accept any sequence of CRs and LFs as a line break. 
</p><p>Second, there is an optional header line, but the format for the
   header line is exactly like a regular record and you can only
   figure out whether it exists from the mime type, which may not be
   available. I ignore the issues of header lines and simply turn them
   into regular records.
</p><p>Third, there is an inconsistency, in that the formal grammar
   specifies that fields can contain only certain US ASCII characters,
   but the specification of the MIME type allows for other character
   sets. I will allow all characters in fields, except for commas, CRs
   and LFs in unquoted fields. This should make it possible to parse
   CSV files in any encoding, but it allows for characters such as
   tabs that the RFC may be interpreted to forbid even in non-US-ASCII
   character sets. 
</p><p>NOTE: Several people have asked me to implement extensions that are
   used in non-US versions Microsoft Excel. This library implements
   RFC-compliant CSV, not Microsoft Excel CSV. If you want to write a
   library that deals with the CSV-like formats used by non-US versions
   of Excel or any other software, you should write a separate library. I
   suggest you call it Text.SSV, for <a href="Something Separated Values-.html">Something Separated Values.</a>
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">type</span> <a href="#t:CSV">CSV</a> = [<a href="Text-CSV.html#t:Record">Record</a>]</li><li class="src short"><span class="keyword">type</span> <a href="#t:Record">Record</a> = [<a href="Text-CSV.html#t:Field">Field</a>]</li><li class="src short"><span class="keyword">type</span> <a href="#t:Field">Field</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></li><li class="src short"><a href="#v:csv">csv</a> :: <a href="/usr/share/doc/ghc/html/libraries/parsec-3.1.1/Text-Parsec-String.html#t:Parser">Parser</a> <a href="Text-CSV.html#t:CSV">CSV</a></li><li class="src short"><a href="#v:parseCSV">parseCSV</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/parsec-3.1.1/Text-Parsec-Error.html#t:ParseError">ParseError</a> <a href="Text-CSV.html#t:CSV">CSV</a></li><li class="src short"><a href="#v:parseCSVFromFile">parseCSVFromFile</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/parsec-3.1.1/Text-Parsec-Error.html#t:ParseError">ParseError</a> <a href="Text-CSV.html#t:CSV">CSV</a>)</li><li class="src short"><a href="#v:parseCSVTest">parseCSVTest</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:printCSV">printCSV</a> :: <a href="Text-CSV.html#t:CSV">CSV</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:CSV" class="def">CSV</a> = [<a href="Text-CSV.html#t:Record">Record</a>]<a href="src/Text-CSV.html#CSV" class="link">Source</a></p><div class="doc"><p>A CSV file is a series of records. According to the RFC, the
 records all have to have the same length. As an extension, I
 allow variable length records.
</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Record" class="def">Record</a> = [<a href="Text-CSV.html#t:Field">Field</a>]<a href="src/Text-CSV.html#Record" class="link">Source</a></p><div class="doc"><p>A record is a series of fields
</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Field" class="def">Field</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a><a href="src/Text-CSV.html#Field" class="link">Source</a></p><div class="doc"><p>A field is a string
</p></div></div><div class="top"><p class="src"><a name="v:csv" class="def">csv</a> :: <a href="/usr/share/doc/ghc/html/libraries/parsec-3.1.1/Text-Parsec-String.html#t:Parser">Parser</a> <a href="Text-CSV.html#t:CSV">CSV</a><a href="src/Text-CSV.html#csv" class="link">Source</a></p><div class="doc"><p>A Parsec parser for parsing CSV files
</p></div></div><div class="top"><p class="src"><a name="v:parseCSV" class="def">parseCSV</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/parsec-3.1.1/Text-Parsec-Error.html#t:ParseError">ParseError</a> <a href="Text-CSV.html#t:CSV">CSV</a><a href="src/Text-CSV.html#parseCSV" class="link">Source</a></p><div class="doc"><p>Given a file name (used only for error messages) and a string to
 parse, run the parser.
</p></div></div><div class="top"><p class="src"><a name="v:parseCSVFromFile" class="def">parseCSVFromFile</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/parsec-3.1.1/Text-Parsec-Error.html#t:ParseError">ParseError</a> <a href="Text-CSV.html#t:CSV">CSV</a>)<a href="src/Text-CSV.html#parseCSVFromFile" class="link">Source</a></p><div class="doc"><p>Given a file name, read from that file and run the parser
</p></div></div><div class="top"><p class="src"><a name="v:parseCSVTest" class="def">parseCSVTest</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/Text-CSV.html#parseCSVTest" class="link">Source</a></p><div class="doc"><p>Given a string, run the parser, and print the result on stdout.
</p></div></div><div class="top"><p class="src"><a name="v:printCSV" class="def">printCSV</a> :: <a href="Text-CSV.html#t:CSV">CSV</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a><a href="src/Text-CSV.html#printCSV" class="link">Source</a></p><div class="doc"><p>Given an object of type CSV, generate a CSV formatted
 string. Always uses escaped fields.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.9.2</p></div></body></html>