From: Pierre Langlois <pierre.langlois@gmx.com>
To: 36194@debbugs.gnu.org
Subject: [bug#36194] [PATCH 10/10] gnu: Add csvkit.
Date: Thu, 13 Jun 2019 16:07:21 +0100 [thread overview]
Message-ID: <20190613150721.26314-1-pierre.langlois@gmx.com> (raw)
In-Reply-To: <20190613150126.17280-1-pierre.langlois@gmx.com>
* gnu/packages/wireservice.scm (csvkit): New variable.
* gnu/packages/patches/csvkit-fix-tests.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---
gnu/local.mk | 1 +
gnu/packages/patches/csvkit-fix-tests.patch | 45 +++++++++++++
gnu/packages/wireservice.scm | 73 +++++++++++++++++++++
3 files changed, 119 insertions(+)
create mode 100644 gnu/packages/patches/csvkit-fix-tests.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index e9e5009276..b49592b5d5 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -734,6 +734,7 @@ dist_patch_DATA = \
%D%/packages/patches/cpufrequtils-fix-aclocal.patch \
%D%/packages/patches/crawl-upgrade-saves.patch \
%D%/packages/patches/crda-optional-gcrypt.patch \
+ %D%/packages/patches/csvkit-fix-tests.patch \
%D%/packages/patches/clucene-contribs-lib.patch \
%D%/packages/patches/cube-nocheck.patch \
%D%/packages/patches/cursynth-wave-rand.patch \
diff --git a/gnu/packages/patches/csvkit-fix-tests.patch b/gnu/packages/patches/csvkit-fix-tests.patch
new file mode 100644
index 0000000000..e62b601fe4
--- /dev/null
+++ b/gnu/packages/patches/csvkit-fix-tests.patch
@@ -0,0 +1,45 @@
+diff --git a/tests/test_utilities/test_csvsql.py b/tests/test_utilities/test_csvsql.py
+index e6ec4af..4f47980 100644
+--- a/tests/test_utilities/test_csvsql.py
++++ b/tests/test_utilities/test_csvsql.py
+@@ -197,7 +197,7 @@ class TestCSVSQL(CSVKitTestCase, EmptyFileTests):
+ utility.run()
+ output = output_file.getvalue()
+ output_file.close()
+- self.assertEqual(output, 'a,b,c\n1,2,3\n0,5,6\n')
++ self.assertEqual(output, 'a,b,c\n1,2.0,3.0\n0,5.0,6.0\n')
+
+ def test_no_prefix_unique_constraint(self):
+ self.get_output(['--db', 'sqlite:///' + self.db_file, '--insert', 'examples/dummy.csv', '--unique-constraint', 'a'])
+diff --git a/tests/test_utilities/test_sql2csv.py b/tests/test_utilities/test_sql2csv.py
+index a0c3d3e..babcfd6 100644
+--- a/tests/test_utilities/test_sql2csv.py
++++ b/tests/test_utilities/test_sql2csv.py
+@@ -121,23 +121,23 @@ class TestSQL2CSV(CSVKitTestCase, EmptyFileTests):
+ input_file.close()
+
+ def test_unicode(self):
+- expected = self.csvsql('examples/test_utf8.csv')
++ self.csvsql('examples/test_utf8.csv')
+ csv = self.get_output(['--db', 'sqlite:///' + self.db_file, '--query', 'select * from foo'])
+- self.assertEqual(csv.strip(), expected)
++ self.assertEqual(csv.strip(), 'foo,bar,baz\n1.0,2.0,3\n4.0,5.0,ʤ')
+
+ def test_no_header_row(self):
+ self.csvsql('examples/dummy.csv')
+ csv = self.get_output(['--db', 'sqlite:///' + self.db_file, '--no-header-row', '--query', 'select * from foo'])
+
+ self.assertTrue('a,b,c' not in csv)
+- self.assertTrue('1,2,3' in csv)
++ self.assertTrue('1,2.0,3.0' in csv)
+
+ def test_linenumbers(self):
+ self.csvsql('examples/dummy.csv')
+ csv = self.get_output(['--db', 'sqlite:///' + self.db_file, '--linenumbers', '--query', 'select * from foo'])
+
+ self.assertTrue('line_number,a,b,c' in csv)
+- self.assertTrue('1,1,2,3' in csv)
++ self.assertTrue('1,1,2.0,3.0' in csv)
+
+ def test_wildcard_on_sqlite(self):
+ self.csvsql('examples/iris.csv')
diff --git a/gnu/packages/wireservice.scm b/gnu/packages/wireservice.scm
index 78c2a4264d..ab86f21f2f 100644
--- a/gnu/packages/wireservice.scm
+++ b/gnu/packages/wireservice.scm
@@ -19,6 +19,7 @@
(define-module (gnu packages wireservice)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system python)
+ #:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (gnu packages)
@@ -191,3 +192,75 @@ for dbf files support to all @code{agate.Table} instances.")))
(synopsis "Add read support for Excel files (xls and xlsx) to agate")
(description "@code{agateexcel} uses a monkey patching pattern to add read
for xls and xlsx files support to all @code{agate.Table} instances.")))
+
+(define-public csvkit
+ (package
+ (name "csvkit")
+ (version "1.0.4")
+ (source (origin
+ (method url-fetch)
+ (uri (pypi-uri "csvkit" version))
+ (sha256
+ (base32
+ "1830lb95rh1iyi3drlwxzb6y3pqkii0qiyzd40c1kvhvaf1s6lqk"))
+ (patches (search-patches "csvkit-fix-tests.patch"))))
+ (build-system python-build-system)
+ (native-inputs
+ `(("python-psycopg2" ,python-psycopg2) ;; Used to test PostgreSQL support.
+ ("python-sphinx" ,python-sphinx)
+ ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)))
+ (inputs
+ `(("python-agate-dbf" ,python-agate-dbf)
+ ("python-agate-excel" ,python-agate-excel)
+ ("python-agate-sql" ,python-agate-sql)
+ ("python-six" ,python-six)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'install 'install-docs
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (man1 (string-append out "/share/man/man1")))
+ (with-directory-excursion "docs"
+ (invoke "make" "man")
+ (copy-recursively "_build/man" man1))
+ #t))))))
+ (home-page "https://csvkit.rtfd.org")
+ (synopsis "Command-line tools for working with CSV")
+ (description "csvkit is a suite of command-line tools for converting to
+and working with CSV. It provides the following commands:
+@itemize
+@item Input:
+ @itemize
+ @item @command{in2csv}: Convert various formats to CSV.
+ @item @command{sql2csv}: Execute SQL commands on a database and return the
+data as CSV.
+ @end itemize
+@item Processing:
+ @itemize
+ @item @command{csvclean}: Remove common syntax errors.
+ @item @command{csvcut}: Filter and truncate CSV files.
+ @item @command{csvgrep}: Filter tabular data to only those rows where
+certain columns contain a given value or match a regular expression.
+ @item @command{csvjoin}: Merges two or more CSV tables together using a
+method analogous to SQL JOIN operation.
+ @item @command{csvsort}: Sort CSV files.
+ @item @command{csvstack}: Stack up the rows from multiple CSV files,
+optionally adding a grouping value to each row.
+ @end itemize
+@item Output and analysis:
+ @itemize
+ @item @command{csvformat}: Convert a CSV file to a custom output format.
+ @item @command{csvjson}: Converts a CSV file into JSON or GeoJSON.
+ @item @command{csvlook}: Renders a CSV to the command line in a
+Markdown-compatible, fixed-width format.
+ @item @command{csvpy}: Loads a CSV file into a @code{agate.csv.Reader}
+object and then drops into a Python shell so the user can inspect the data
+however they see fit.
+ @item @command{csvsql}: Generate SQL statements for a CSV file or execute
+those statements directly on a database.
+ @item @command{csvstat}: Prints descriptive statistics for all columns in a
+CSV file.
+ @end itemize
+@end itemize")
+ (license license:expat)))
--
2.22.0
next prev parent reply other threads:[~2019-06-13 15:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 15:01 [bug#36194] [PATCH 00/10] Add csvkit Pierre Langlois
2019-06-13 15:06 ` [bug#36194] [PATCH 01/10] gnu: Add python-slugify Pierre Langlois
2019-06-13 15:06 ` [bug#36194] [PATCH 02/10] gnu: Add python-pytimeparse Pierre Langlois
2019-06-13 15:06 ` [bug#36194] [PATCH 03/10] gnu: Add python-crate Pierre Langlois
2019-06-13 15:06 ` [bug#36194] [PATCH 04/10] gnu: Add python-dbfread Pierre Langlois
2019-06-13 15:06 ` [bug#36194] [PATCH 05/10] gnu: Add python-leather Pierre Langlois
2019-07-07 13:47 ` bug#36194: " Ludovic Courtès
2019-07-07 14:35 ` [bug#36194] " Pierre Langlois
2019-06-13 15:06 ` [bug#36194] [PATCH 06/10] gnu: Add python-agate Pierre Langlois
2019-06-13 15:06 ` [bug#36194] [PATCH 07/10] gnu: Add python-agate-sql Pierre Langlois
2019-06-13 15:06 ` [bug#36194] [PATCH 08/10] gnu: Add python-agate-dbf Pierre Langlois
2019-06-13 15:06 ` [bug#36194] [PATCH 09/10] gnu: Add python-agate-excel Pierre Langlois
2019-06-21 10:42 ` [bug#36194] [PATCH 01/10 v2] gnu: Add python-slugify Pierre Langlois
2019-06-13 15:07 ` Pierre Langlois [this message]
2019-07-06 20:01 ` [bug#36194] [PATCH 00/10] Add csvkit Pierre Langlois
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190613150721.26314-1-pierre.langlois@gmx.com \
--to=pierre.langlois@gmx.com \
--cc=36194@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.