Skip to content
Commits on Source (7)
......@@ -5,3 +5,4 @@ TODO
*.install
data/
packages
.~*
\ No newline at end of file
export OPAMYES=1
if [ -f "$HOME/.opam/config" ]; then
opam update
opam upgrade
else
opam init
fi
if [ -n "${OPAM_SWITCH}" ]; then
opam switch ${OPAM_SWITCH}
fi
eval `opam config env`
export OCAMLRUNPARAM=b
opam pin -y add csv .
opam pin -y add csv-lwt .
language: c
sudo: false
addons:
apt:
sources:
- avsm
packages:
- ocaml
- ocaml-native-compilers
- opam
script: bash -ex .travis-ci.sh
sudo: required
install: test -e .travis.opam.sh || wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh
script: bash -ex .travis-opam.sh
env:
- OPAM_SWITCH=4.03.0
- OPAM_SWITCH=4.04.0
- OPAM_SWITCH=4.06.1
- OPAM_SWITCH=4.07.0
cache:
directories:
- $HOME/.opam
global:
- PINS="csv.dev:. csv-lwt.dev:."
matrix:
- OCAML_VERSION=4.03 PACKAGE="csv.dev"
- OCAML_VERSION=4.04 PACKAGE="csv.dev"
- OCAML_VERSION=4.06 PACKAGE="csv.dev"
- OCAML_VERSION=4.07 PACKAGE="csv.dev"
- OCAML_VERSION=4.07 PACKAGE="csv-lwt.dev"
os:
- linux
- osx
2.4 2019-12-09
--------------
- Fixes the build on Windows with CRLF checkout (@dra27).
- Allows use of the repo in a Duniverse (@dra27).
2.3 2019-09-09
--------------
- Be compatible with OCaml ≥ 4.08 (fixes #28).
- Put `csvtool` in its own package.
- Use UTF-8 to determine column widths for the "readable" format
(fixes #21).
- Add deprecation attributes.
- Fix alignment in `csvtool` usage message.
- Small improvements to the documentation.
2.2 2018-11-04
--------------
......
......@@ -12,10 +12,11 @@ install uninstall clean:
dune $@
doc: build
sed -e 's/%%VERSION%%/$(PKGVERSION)/' src/csv.mli \
> _build/default/src/csv.mli
dune build @doc
echo '.def { background: #f0f0f0; }' >> _build/default/_doc/odoc.css
sed -e 's/%%VERSION%%/$(PKGVERSION)/' --in-place \
_build/default/_doc/_html/csv/Csv/index.html \
_build/default/_doc/_html/csv-lwt/Csv_lwt/index.html
upload-doc: doc
scp -C -p -r _build/default/_doc/csv/ $(WEB)
......
......@@ -27,6 +27,14 @@ make sure you have [dune][] and run
dune install csv
dune install csv-lwt
For the command line manipulation utility, do
opam install csvtool
or
dune install csvtool
[OPAM]: https://opam.ocaml.org/
[dune]: https://github.com/ocaml/dune
......@@ -38,11 +46,14 @@ With OPAM:
opam remove csv
opam remove csv-lwt
opam remove csvtool
Manually (from the source directory):
dune uninstall csv
dune uninstall csv-lwt
dune uninstall csvtool
Documentation
-------------
......
......@@ -4,7 +4,7 @@ let ( / ) = Filename.concat
let read_all fname =
(* Avoid Bytes for backward compatibility. *)
let fh = open_in fname in
let fh = open_in_bin fname in
let len = in_channel_length fh in
let b = Buffer.create len in
Buffer.add_channel b fh len;
......
......@@ -16,7 +16,7 @@ build: [
depends: [
"ocaml" {>= "4.03.0"}
"csv"
"dune" {build}
"dune"
"base-bytes"
"base-unix"
"lwt"
......@@ -26,6 +26,5 @@ description: """
This is a pure OCaml library to read and write CSV files, including
all extensions used by Excel — e.g. quotes, newlines, 8 bit characters
in fields, \"0 etc. A special representation of rows of CSV files with
a header is provided. The library comes with a handy command line tool
called csvtool for handling CSV files from shell scripts. This
version can be used with the monadic concurrency library LWT."""
a header is provided. This version can be used with the monadic
concurrency library LWT."""
......@@ -15,7 +15,7 @@ build: [
]
depends: [
"ocaml" {>= "4.03.0"}
"dune" {build}
"dune"
"base-bytes"
"base-unix"
]
......@@ -24,5 +24,4 @@ description: """
This is a pure OCaml library to read and write CSV files, including
all extensions used by Excel — e.g. quotes, newlines, 8 bit characters
in fields, \"0 etc. A special representation of rows of CSV files with
a header is provided. The library comes with a handy command line tool
called csvtool for handling CSV files from shell scripts."""
a header is provided."""
opam-version: "2.0"
maintainer: "Christophe Troestler <Christophe.Troestler@umons.ac.be>"
authors: [ "Richard Jones"
"Christophe Troestler" ]
tags: ["csv" "database" "science"]
license: "LGPL-2.1 with OCaml linking exception"
homepage: "https://github.com/Chris00/ocaml-csv"
dev-repo: "git+https://github.com/Chris00/ocaml-csv.git"
bug-reports: "https://github.com/Chris00/ocaml-csv/issues"
doc: "https://Chris00.github.io/ocaml-csv/doc"
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
["dune" "runtest" "-p" name "-j" jobs] {with-test}
]
depends: [
"ocaml" {>= "4.03.0"}
"dune"
"base-bytes"
"base-unix"
"csv" {= version}
"uutf"
]
synopsis: "Command line tool for handling CSV files"
description: """
This is a handy command line tool for handling CSV files from shell
scripts based on the library `csv`."""
......@@ -204,9 +204,18 @@ let cmd_height ~input_sep ~chan files =
Csv.fold_left ~f:(fun h _ -> h + 1) ~init:h csv_in) in
fprintf chan "%d\n" height
let length_utf8 s =
Uutf.String.fold_utf_8
(fun cnt _ char ->
match char with
| `Uchar c ->
if Uchar.equal c Uutf.u_bom then cnt else cnt + 1
| `Malformed s -> failwith(sprintf "Malformed UTF-8 char \"%s\"" s))
0 s
let cmd_readable ~input_sep ~chan files =
let csv = List.concat (List.map (Csv.load ~separator:input_sep) files) in
Csv.save_out_readable chan csv
Csv.save_out_readable chan csv ~length:length_utf8
let cmd_cat ~input_sep ~output_sep ~chan files =
(* Avoid loading the whole file into memory. *)
......@@ -539,7 +548,7 @@ let cmd_join ~input_sep ~output_sep ~chan colspec1 colspec2 files =
List.hd (Csv.set_columns ~cols:value_width [["!MULTIPLE VALUES"]]) in
(* Generate output CSV. *)
let keys = List.sort Pervasives.compare keys in
let keys = List.sort compare keys in
let keys = List.map (fun key -> key, []) keys in
let csv = List.fold_left (
fun keys hash ->
......
(executables
(names csvtool)
(public_names csvtool)
(package csvtool)
(libraries csv unix uutf))
(rule
(targets test-utf8.output)
(deps test-utf8.csv)
(action (with-stdout-to test-utf8.output
(run %{exe:csvtool.exe} readable test-utf8.csv))))
(alias
(name runtest)
(package csvtool)
(action (diff test-utf8.expected test-utf8.output)))
Cell 11,Cell 12,Cell 13
Français êéèëü,Gauß,
BYTE, ORDER, MARK
∫₀¹ ϕ,a₂₂,a₂₃
Cell 11 Cell 12 Cell 13
Français êéèëü Gauß
BYTE ORDER MARK
∫₀¹ ϕ a₂₂ a₂₃
ocaml-csv (2.2-2) UNRELEASED; urgency=medium
ocaml-csv (2.4-1) unstable; urgency=medium
* New upstream release
* Remove Lifeng from Uploaders (Closes: #925076)
* Bump Standards-Version to 4.4.1
* Add Rules-Requires-Root: no
* Build-depend on debhelper-compat and remove debian/compat
-- Stéphane Glondu <glondu@debian.org> Thu, 08 Aug 2019 10:11:37 +0200
-- Stéphane Glondu <glondu@debian.org> Thu, 19 Dec 2019 12:47:16 +0100
ocaml-csv (2.2-1) unstable; urgency=medium
......
......@@ -4,15 +4,17 @@ Maintainer: Debian OCaml Maintainers <debian-ocaml-maint@lists.debian.org>
Uploaders:
Stéphane Glondu <glondu@debian.org>
Build-Depends:
debhelper (>= 12),
debhelper-compat (= 12),
dh-ocaml (>= 0.9),
ocaml-nox (>= 3.11.1-3~),
ocaml-findlib (>= 1.2.5),
dune,
ocaml-dune,
libuutf-ocaml-dev,
opam-installer,
xsltproc,
docbook-xsl
Standards-Version: 4.4.0
Standards-Version: 4.4.1
Rules-Requires-Root: no
Section: ocaml
Homepage: https://github.com/Chris00/ocaml-csv
Vcs-Git: https://salsa.debian.org/ocaml-team/ocaml-csv.git
......
usr/doc/csvtool/*
/usr/bin
@OCamlStdlibDir@/csvtool