From 965ac504daf608395a35ce00c4345a45a90db5f3 Mon Sep 17 00:00:00 2001 From: Christian Ramseyer Date: Mon, 23 Jul 2018 13:50:43 +0200 Subject: [PATCH 1/2] Fix delimiter option not considered (#51) --- es2csv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/es2csv.py b/es2csv.py index 054d1ec..5022142 100755 --- a/es2csv.py +++ b/es2csv.py @@ -209,7 +209,7 @@ def write_to_csv(self): self.num_results = sum(1 for line in codecs.open(self.tmp_file, mode='r', encoding='utf-8')) if self.num_results > 0: output_file = codecs.open(self.opts.output_file, mode='a', encoding='utf-8') - csv_writer = csv.DictWriter(output_file, fieldnames=self.csv_headers) + csv_writer = csv.DictWriter(output_file, fieldnames=self.csv_headers, delimiter=unicode(self.opts.delimiter)) csv_writer.writeheader() timer = 0 widgets = ['Write to csv ', From bad89a6301b6381e3c57f00244b2aa47b879f3c1 Mon Sep 17 00:00:00 2001 From: Christian Ramseyer Date: Mon, 25 Nov 2019 14:42:56 +0100 Subject: [PATCH 2/2] Merge upstream-unacknowledged PR * https://github.com/taraslayshchuk/es2csv/pull/71 * from fork https://github.com/gboddin/es2csv/tree/es-7.0 * thanks gboddin! --- es2csv.py | 5 +++-- requirements.txt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/es2csv.py b/es2csv.py index 5022142..34a6cfb 100755 --- a/es2csv.py +++ b/es2csv.py @@ -112,7 +112,7 @@ def next_scroll(scroll_id): search_args['q'] = query if '_all' not in self.opts.fields: - search_args['_source_include'] = ','.join(self.opts.fields) + search_args['_source_includes'] = self.opts.fields self.csv_headers.extend([unicode(field, "utf-8") for field in self.opts.fields if '*' not in field]) if self.opts.debug_mode: @@ -124,7 +124,7 @@ def next_scroll(scroll_id): print('Sorting by: {}.'.format(', '.join(self.opts.sort))) res = self.es_conn.search(**search_args) - self.num_results = res['hits']['total'] + self.num_results = res['hits']['total']['value'] print('Found {} results.'.format(self.num_results)) if self.opts.debug_mode: @@ -237,3 +237,4 @@ def clean_scroll_ids(self): self.es_conn.clear_scroll(body=','.join(self.scroll_ids)) except: pass + diff --git a/requirements.txt b/requirements.txt index 7eac152..9f8057e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -elasticsearch>=5.5.2,<5.6.0 +elasticsearch>= 7.0.1 progressbar2>=3.36.0,<3.37.0 backports.csv>=1.0.5,<1.1.0