Skip to content

Commit

Permalink
updated CSV readme
Browse files Browse the repository at this point in the history
  • Loading branch information
juerg committed Oct 31, 2023
1 parent f9fa034 commit 604cf3c
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions doc/readme/csv.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,25 @@ a comma and a double quote.
(csv/read """
8000,"Zurich",ZH
5000,"Aarau",AG
"""))
""")

;; => (["8000" "Zurich" "ZH"]
;; ["5000" "Aarau" "AG"])
;; => (("8000" "Zurich" "ZH") ("5000" "Aarau" "AG"))
```

With alternate quote and separator:

```clojure
(csv/read """
8000,'Zurich','Wipkingen, X-''1''',ZH
8000,'Zurich','Wipkingen, Meier''s Ring',ZH
3000,'Bern','',BE
5000,'Aarau',,,
5000,'Aarau',,
"""
:separator ","
:quote "'")

;; => (["8000" "Zurich" "Wipkingen, X-'1'" "ZH"]
;; ["3000" "Bern" "" "BE"]
;; ["5000" "Aarau" nil nil])
;; => (("8000" "Zurich" "Wipkingen, Meier's Ring" "ZH")
;; ("3000" "Bern" "" "BE")
;; ("5000" "Aarau" nil nil))
```


Expand All @@ -44,7 +43,7 @@ Writes data in CSV format to a string or a Java Writer
```clojure
(csv/write-str [[1 "AC" false] [2 "WS" true]])

;; => "1,AC,false\n2,WS,true"
;; => "1,AC,false\n2,WS,true"
```

With alternate quote, separator, and newline:
Expand All @@ -55,12 +54,12 @@ With alternate quote, separator, and newline:
:separator ";"
:newline :cr+lf)

;; => "1;AC;false\r\n2;'WS;''-1';true"
;; => "1;AC;false\r\n2;'WS;''-1''';true"
```


Writes data in CSV format to a file:

```clojure
(csv/write (io/file "test.csv") [[1 "AC" false] [2 "WS" true]])
``
```

0 comments on commit 604cf3c

Please sign in to comment.