From 12cffd6d0655b79d7bd150b816f38aeef2f9a262 Mon Sep 17 00:00:00 2001 From: James McKinney Date: Fri, 14 Jul 2017 23:04:27 -0400 Subject: [PATCH] in2csv adds a --encoding-xls option to specify the encoding of the input XLS file, fixes #849 --- CHANGELOG.rst | 4 ++++ csvkit/utilities/in2csv.py | 4 +++- requirements-py3.txt | 8 +++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 34b7a22e1..7f477c436 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,10 @@ 1.0.3 ----- +Improvements: + +* :doc:`/scripts/in2csv` adds a :code:`--encoding-xls` option to specify the encoding of the input XLS file. + Fixes: * :doc:`/scripts/csvgrep` accepts utf-8 arguments to the :code:`--match` and :code:`--regex` options in Python 2. diff --git a/csvkit/utilities/in2csv.py b/csvkit/utilities/in2csv.py index d31252225..49843000f 100644 --- a/csvkit/utilities/in2csv.py +++ b/csvkit/utilities/in2csv.py @@ -46,6 +46,8 @@ def option_parser(bytestring): help='The name of the Excel sheet to operate on.') self.argparser.add_argument('--write-sheets', dest='write_sheets', type=option_parser, help='The names of the Excel sheets to write to files, or "-" to write all sheets.') + self.argparser.add_argument('--encoding-xls', dest='encoding_xls', + help='Specify the encoding of the input XLS file.') self.argparser.add_argument('-y', '--snifflimit', dest='sniff_limit', type=int, help='Limit CSV dialect sniffing to the specified number of bytes. Specify "0" to disable sniffing entirely.') self.argparser.add_argument('-I', '--no-inference', dest='no_inference', action='store_true', @@ -139,7 +141,7 @@ def main(self): elif filetype == 'ndjson': table = agate.Table.from_json(self.input_file, key=self.args.key, newline=True, **kwargs) elif filetype == 'xls': - table = agate.Table.from_xls(self.input_file, sheet=self.args.sheet, **kwargs) + table = agate.Table.from_xls(self.input_file, sheet=self.args.sheet, encoding_override=self.args.encoding_xls, **kwargs) elif filetype == 'xlsx': table = agate.Table.from_xlsx(self.input_file, sheet=self.args.sheet, **kwargs) elif filetype == 'dbf': diff --git a/requirements-py3.txt b/requirements-py3.txt index 8c1ef498d..fbe47536e 100644 --- a/requirements-py3.txt +++ b/requirements-py3.txt @@ -1,11 +1,9 @@ agate>=1.5.5 -# Using HEAD until agate-excel>0.2.0 is available. -# agate-excel>=0.2.0 +# Using HEAD until agate-excel>=0.2.2 is available. +# agate-excel>=0.2.2 -e git+https://github.com/wireservice/agate-excel.git#egg=agateexcel agate-dbf>=0.2.0 -# Using HEAD until agate-sql>0.5.0 is available. -# agate-excel>=0.2.0 --e git+https://github.com/wireservice/agate-sql.git#egg=agatesql +agate-sql>=0.5.2 six>=1.6.1 # Development