Changeset 34224 in project


Ignore:
Timestamp:
07/03/17 22:03:59 (5 months ago)
Author:
kon
Message:

rel 0.11.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/csv-xml

    r34219 r34224  
    88== Documentation
    99
    10 A CHICKEN version of "csv-scheme".
     10A CHICKEN version of "csv-scheme". Some additions/extensions to the original.
    1111
    1212=== Input
    1313
    1414See [[http://www.neilvandyke.org/csv-scheme/|csv-scheme]] for the full documentation.
    15 
    16 ==== reader-spec
    17 
    18 <procedure>(reader-spec [(newline-type 'lax) (separator-chars '(#\,)) (quote-char #\") (quote-doubling-escapes? #t) (comment-chars '()) (whitespace-chars '(#\space)) (strip-leading-whitespace? #f) (strip-trailing-whitespace? #f) (newlines-in-quotes? #t)]) => csv-reader-spec</procedure>
    19 
    20 Returns a {{csv-reader-spec}}.
    2115
    2216==== csv-reader?
     
    3327
    3428<procedure>(error-csv-reader LOC OBJECT [ARG-MESSAGE []])</procedure>
     29
     30==== reader-spec
     31
     32<procedure>(reader-spec [(newline-type 'lax) (separator-chars '(#\,)) (quote-char #\") (quote-doubling-escapes? #t) (comment-chars '()) (whitespace-chars '(#\space)) (strip-leading-whitespace? #f) (strip-trailing-whitespace? #f) (newlines-in-quotes? #t)]) => csv-reader-spec</procedure>
    3533
    3634==== csv-reader-spec?
     
    5351==== make-csv-writer-maker
    5452
    55 <procedure>(make-csv-writer-maker WRITER-SPEC) => procedure</procedure>
     53<procedure>(make-csv-writer-maker [WRITER-SPEC]) =>  (#!optional csv-writer-spec -> ((or output-port string) -> (* -> undefined)))</procedure>
     54
     55See {{writer-spec}} below for the default {{WRITER-SPEC}}.
    5656
    5757==== make-csv-writer
    5858
    59 <procedure>(make-csv-writer OUT-OR-STR [WRITER-SPEC]) => csv-writer-procedure</procedure>
     59<procedure>(make-csv-writer OUT-OR-STR [WRITER-SPEC]) => (* -> undefined)</procedure>
    6060
    61 {{OUT-OR-STR}} is {{output-port}} or {{string}}. {{string}} is a {{pathname}}.
     61Returns a {{procedure}} of 1 argument, a {{scheme-object}}, the {{ROW-DATA-OBJECT}}.
    6262
    63 ==== list->csv
     63{{OUT-OR-STR}} is {{output-port}} or {{string}}. A {{string}} is interpreted
     64as a {{pathname}} to yield an {{output-port}}.
    6465
    65 <procedure>(list->csv LS [WRITER-OR-OUT])</procedure>
     66See {{writer-spec}} below for the default {{WRITER-SPEC}}.
    6667
    67 {{LS}} is a {{list-of list}}. {{WRITER-OR-OUT}} is a {{csv-writer}} or {{output-port}}.
     68When the {{ROW-DATA-OBJECT}} is a {{list}} then it is interpreted as
     69row data. Otherwise assumed to be a comment.
    6870
    69 ==== list->sxml
    70 
    71 <procedure>(list->sxml LS [(row-element 'row) (column-elements (col-0...))]) => list</procedure>
    72 
    73 {{LS}} is a {{list-of list}}.
    74 
    75 <enscript language=scheme>
    76 (list->sxml '((1 22 333) (11 2222 333333)))
    77 ;=> (
    78   *TOP*
    79   (row
    80     (col-0 1)
    81     (col-0 22)
    82     (col-0 333))
    83   (row
    84     (col-1 11)
    85     (col-1 2222)
    86     (col-1 333333))
    87 )
    88 </enscript>
    89 
    90 ==== writer-spec
    91 
    92 <procedure>(writer-spec [(newline #t) (separator-char #\,) (quote-char #\")]) => boolean</procedure>
    93 
    94 Returns a {{csv-writer-spec}}.
    95 
    96 {{newline}} is {{#t}}, {{cr}}, {{lf}}, {{crlf}}. {{#t}} is the platform default.
     71The {{ROW-DATA-OBJECT}} argument will be converted to an output {{string}},
     72according to the associated {{csv-writer-spec}}, and printed to the associated
     73{{output-port}}.
    9774
    9875==== csv-writer?
     
    11087<procedure>(error-csv-writer LOC OBJECT [ARG-MESSAGE []])</procedure>
    11188
     89==== writer-spec
     90
     91<procedure>(writer-spec [(newline-char #t) (separator-char #\,) (quote-char #\") (comment-char #\#) (quote-doubling-escapes? #t) (quote-controls? #t)]) => csv-writer-spec</procedure>
     92
     93{{NEWLINE-CHAR}} is {{#t}}, {{cr}}, {{lf}}, or {{crlf}}. {{#t}} is the platform default.
     94
     95{{COMMENT-CHAR}} is {{#f}}, or a {{character}}. {{#f}} means no comment support.
     96{{#\#}} is the default.
     97
     98{{quote-doubling-escapes?}} and {{quote-controls?}} are currently ignored.
     99
    112100==== csv-writer-spec?
    113101
     
    124112<procedure>(error-csv-writer-spec LOC OBJECT [ARG-MESSAGE []])</procedure>
    125113
     114==== list->csv
     115
     116<procedure>(list->csv LS [WRITER-OR-OUT])</procedure>
     117
     118{{LS}} is a {{list-of list | string}}, a list of row-item.
     119
     120{{WRITER-OR-OUT}} is a {{csv-writer}} or {{output-port}}. Default is the
     121{{(current-output-port)}}. Note that when an {{output-port}} is specified the
     122default {{csv-writer-spec}} will be used.
     123
     124When the current row-item is a {{string}}, and not a {{list}}, then it is
     125treated as a line-comment. Note that comments are processed only when the
     126associated {{csv-writer-spec}} {{comment-char}} is a {{character}}.
     127
     128<enscript language=scheme>
     129;assumes string output & comment-char is #\#
     130(list->csv '((1 22 333) "a comment" (11 2222 333333)))
     131;=> "\"1\",\"22\",\"333\"\n#a comment\n\"11\",\"2222\",\"333333\"\n"
     132</enscript>
     133
    126134
    127135== Usage
     
    136144Neil van Dyke
    137145
    138 for Chicken by [[kon lovett|Kon Lovett]]
     146[[kon lovett|Kon Lovett]] for CHICKEN
    139147
    140148
    141149== Bugs & Limitations
    142150
    143 * The string escape character is "baked-in" and not a component of the
    144 {{reader-specification}}.
     151* The {{quote-doubling-escapes?}} and {{quote-controls?}} are currently ignored.
    145152
    146153
    147154== Version history
    148155
     156; 0.11.1 : Fix {{writer-spec}} defaults.
    149157; 0.11.0 : Add {{reader-spec}}, ''csv-out'' stuff.
    150158; 0.10.2 : Escape character, '\', in quoted strings.
Note: See TracChangeset for help on using the changeset viewer.