Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csv library - add documentation to wiki #37

Open
ghost opened this issue May 20, 2022 · 5 comments
Open

csv library - add documentation to wiki #37

ghost opened this issue May 20, 2022 · 5 comments

Comments

@ghost
Copy link

ghost commented May 20, 2022

Thanks for adding my 'csv' library to cyclone/winds. I could not find a way to edit the wiki, so please see below the documentation, in markdown format.

CSV: (import (cyclone csv))

A CSV reader/writer library. RFC4180 compliant - http://tools.ietf.org/html/rfc4180 - but allowing:

  • choice of separator character, e.g. tab instead of comma
  • choice of quote character, e.g. single instead of double-quote
  • "CR LF", "CR" or "LF" are all accepted as line endings when reading

The CSV reader/writer uses a standard input or output port. Records are retrieved or written as lists of field values. Fields are always read as strings. Fields are written using display unless they are strings needing quoting, when they are written character by character, or symbols, which are first converted to strings.

make-csv-reader

Creates a csv-reader object:

  • no arguments: uses current input port, comma as separator and double-quote for quote character
  • one argument: specifies input port
  • two arguments: specifies input port and separator character
  • three arguments: specifies input port, separator character and quote character

csv-read

Reads a single record (list of fields) from given reader, or current-input-port if no reader given.

csv-read-all

Reads a list of records (list of fields) from given reader, or current-input-port if no reader given.

> (import (cyclone csv) (scheme file))
> (with-input-from-file "data.csv" (lambda () (csv-read-all)))
(("123" "field 2" "456") ("789" "see, comma" "12"))

make-csv-writer

Creates a csv-writer object:

  • no arguments: uses current-output-port, comma as separator and double-quote for quote character
  • one argument: specifies output port
  • two arguments: specifies output port and separator character
  • three arguments: specifies output port, separator character and quote character

csv-write

Writes a single record (list of fields) in CSV format:

  • one argument: the record, writes to the current-output-port with comma as separator and double-quote for quote character
  • two arguments: the record and a csv-writer object

csv-write-all

Writes a list of records in CSV format:

  • one argument: the records, writes to the current-output-port with comma as separator and double-quote for quote character
  • two arguments: the records and a csv-writer object
> (import (cyclone csv) (scheme file))
> (with-output-to-file "data.csv" 
   (lambda () (csv-write-all '((123 "field 2" 456) (789 "see, comma" 012)))))
 
$ more data.csv
123,field 2,456
789,"see, comma",12
@justinethier
Copy link
Contributor

Thanks @pcl-code, I have added this documentation to https://github.com/cyclone-scheme/winds/wiki/csv

@arthurmaciel I can adjust wiki permissions to allow anyone to make modifications. Do you have any concerns with a permissions change?

@arthurmaciel
Copy link
Collaborator

arthurmaciel commented May 23, 2022 via email

@justinethier
Copy link
Contributor

Thanks @arthurmaciel !

Well, I didn't make a permissions change yet but I think I will go ahead and do that later today.

I was trying to remember here. If there is documentation in the winds package, will it automatically update the wiki? I remember discussing this at one point but I don't think we added that automation?

@arthurmaciel
Copy link
Collaborator

@justinethier, If you haven't already made the permissions change, please do it. The idea is to have contributions from the community at the bottom of the wiki pages, after the horizontal rule.

About automation, yes - if there is a README.md in the winds package repo, it will be copied to the wiki and the contributions from the community are added to its bottom.

The automation was implemented a long time ago, but after CVE-2022-24765 was announced and some security changes were made to git itself, the third party actions we used to update the wiki stopped working with our current configuration. After banging my head against the wall, I decided to get rid of external code and the automation is back again (as far as I could test).

Sorry for the delay.

@justinethier
Copy link
Contributor

No worries @arthurmaciel - thanks for the update and fixing the automation!

Permissions were changed right after I posted my last comment here. Sorry, I should have followed-up afterwards to confirm. If anyone has any further issues please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants