Skip to content

NalaGinrut/guile-csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

guile-csv

Guile csv reader

USAGE

install

./configure && make sudo make install

read csv

(use-modules (csv csv))
(define my-csv-reader (make-csv-reader #:\,))
(call-with-input-file "file.csv" my-csv-reader)

csv->xml

(call-with-input-file "file.csv" csv->xml)

and result could be:

<record-0>
 <name>aaa</name>
 <age>11</age>
 <email>[email protected]</email>
</record-0>
<record-1>
 <name>bbb</name>
 <age>12</age>
 <email>[email protected]</email>
</record-1>

sxml->csv or csv-write to output a csv format file

(call-with-output-file "file.csv"
 (lambda (port)
  (sxml->csv 
   '((name age email) ("aaa" "11" "[email protected]") ("bbb" "12" "[email protected]"))
   port)))

and file.csv would be:

name,age,email
aaa,11,[email protected]
bbb,12,[email protected]

Enjoy!