Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-csvkit for openSUSE:Factory checked in at 2023-04-04 21:26:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-csvkit (Old) and /work/SRC/openSUSE:Factory/.python-csvkit.new.19717 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-csvkit" Tue Apr 4 21:26:56 2023 rev:15 rq:1077189 version:1.1.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-csvkit/python-csvkit.changes 2023-01-17 17:35:19.605185593 +0100 +++ /work/SRC/openSUSE:Factory/.python-csvkit.new.19717/python-csvkit.changes 2023-04-04 21:27:05.635466036 +0200 @@ -1,0 +2,7 @@ +Tue Mar 28 10:43:53 UTC 2023 - Dirk Müller <[email protected]> + +- update to 1.1.1: + * feat: :doc:`/scripts/csvstack` handles files with columns in + different orders or with different names. + +------------------------------------------------------------------- Old: ---- csvkit-1.1.0.tar.gz New: ---- csvkit-1.1.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-csvkit.spec ++++++ --- /var/tmp/diff_new_pack.NjbhQl/_old 2023-04-04 21:27:06.171469078 +0200 +++ /var/tmp/diff_new_pack.NjbhQl/_new 2023-04-04 21:27:06.175469101 +0200 @@ -21,7 +21,7 @@ %define skip_python2 1 %define skip_python36 1 Name: python-csvkit -Version: 1.1.0 +Version: 1.1.1 Release: 0 Summary: A library of utilities for working with CSV License: MIT ++++++ csvkit-1.1.0.tar.gz -> csvkit-1.1.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/CHANGELOG.rst new/csvkit-1.1.1/CHANGELOG.rst --- old/csvkit-1.1.0/CHANGELOG.rst 2023-01-03 19:19:54.000000000 +0100 +++ new/csvkit-1.1.1/CHANGELOG.rst 2023-02-22 19:24:33.000000000 +0100 @@ -1,3 +1,8 @@ +1.1.1 - February 22, 2023 +------------------------- + +* feat: :doc:`/scripts/csvstack` handles files with columns in different orders or with different names. + 1.1.0 - January 3, 2023 ----------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/PKG-INFO new/csvkit-1.1.1/PKG-INFO --- old/csvkit-1.1.0/PKG-INFO 2023-01-03 19:21:05.184823800 +0100 +++ new/csvkit-1.1.1/PKG-INFO 2023-02-22 19:26:24.011926000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: csvkit -Version: 1.1.0 +Version: 1.1.1 Summary: A suite of command-line tools for working with CSV, the king of tabular file formats. Home-page: https://github.com/wireservice/csvkit Author: Christopher Groskopf diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/csvkit/cleanup.py new/csvkit-1.1.1/csvkit/cleanup.py --- old/csvkit-1.1.0/csvkit/cleanup.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/csvkit/cleanup.py 2023-01-06 21:32:15.000000000 +0100 @@ -15,7 +15,7 @@ if len(row) == 0: row = [''] - fixed_row[-1] += "%s%s" % (joiner, row[0]) + fixed_row[-1] += "{}{}".format(joiner, row[0]) fixed_row.extend(row[1:]) return fixed_row diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/csvkit/cli.py new/csvkit-1.1.1/csvkit/cli.py --- old/csvkit-1.1.0/csvkit/cli.py 2023-01-03 19:18:09.000000000 +0100 +++ new/csvkit-1.1.1/csvkit/cli.py 2023-02-22 19:25:13.000000000 +0100 @@ -224,7 +224,7 @@ '1-based numbering.') self.argparser.add_argument( - '-V', '--version', action='version', version='%(prog)s 1.1.0', + '-V', '--version', action='version', version='%(prog)s 1.1.1', help='Display version information and exit.') def _open_input_file(self, path): @@ -296,7 +296,7 @@ 'flag or with the PYTHONIOENCODING environment variable. Use the -v flag to see ' 'the complete error.\n' % self.args.encoding) else: - sys.stderr.write('%s: %s\n' % (t.__name__, str(value))) + sys.stderr.write('{}: {}\n'.format(t.__name__, str(value))) sys.excepthook = handler diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/csvkit/grep.py new/csvkit-1.1.1/csvkit/grep.py --- old/csvkit-1.1.0/csvkit/grep.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/csvkit/grep.py 2023-01-06 21:32:15.000000000 +0100 @@ -89,7 +89,7 @@ """ try: # Dictionary of patterns - patterns = dict((k, pattern_as_function(v)) for k, v in patterns.items() if v) + patterns = {k: pattern_as_function(v) for k, v in patterns.items() if v} if not column_names: return patterns p2 = {} @@ -104,7 +104,7 @@ return p2 except AttributeError: # Sequence of patterns - return dict((i, pattern_as_function(x)) for i, x in enumerate(patterns)) + return {i: pattern_as_function(x) for i, x in enumerate(patterns)} def pattern_as_function(obj): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/csvkit/utilities/csvgrep.py new/csvkit-1.1.1/csvkit/utilities/csvgrep.py --- old/csvkit-1.1.0/csvkit/utilities/csvgrep.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/csvkit/utilities/csvgrep.py 2023-01-06 21:32:15.000000000 +0100 @@ -63,7 +63,7 @@ if self.args.regex: pattern = re.compile(self.args.regex) elif self.args.matchfile: - lines = set(line.rstrip() for line in self.args.matchfile) + lines = {line.rstrip() for line in self.args.matchfile} self.args.matchfile.close() def pattern(x): @@ -71,7 +71,7 @@ else: pattern = self.args.pattern - patterns = dict((column_id, pattern) for column_id in column_ids) + patterns = {column_id: pattern for column_id in column_ids} filter_reader = FilteringCSVReader(rows, header=False, patterns=patterns, inverse=self.args.inverse, any_match=self.args.any_match) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/csvkit/utilities/csvpy.py new/csvkit-1.1.1/csvkit/utilities/csvpy.py --- old/csvkit-1.1.0/csvkit/utilities/csvpy.py 2021-07-13 23:10:53.000000000 +0200 +++ new/csvkit-1.1.1/csvkit/utilities/csvpy.py 2023-01-06 21:32:15.000000000 +0100 @@ -38,7 +38,7 @@ variable = klass(self.input_file, **self.reader_kwargs) - welcome_message = 'Welcome! "%s" has been loaded in an %s object named "%s".' % ( + welcome_message = 'Welcome! "{}" has been loaded in an {} object named "{}".'.format( filename, class_name, variable_name) try: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/csvkit/utilities/csvsql.py new/csvkit-1.1.1/csvkit/utilities/csvsql.py --- old/csvkit-1.1.0/csvkit/utilities/csvsql.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/csvkit/utilities/csvsql.py 2023-01-06 21:32:15.000000000 +0100 @@ -224,7 +224,7 @@ queries = [] for query in self.args.queries: if os.path.exists(query): - with open(query, 'r') as f: + with open(query) as f: query = f.read() queries += query.split(';') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/csvkit/utilities/csvstack.py new/csvkit-1.1.1/csvkit/utilities/csvstack.py --- old/csvkit-1.1.0/csvkit/utilities/csvstack.py 2021-07-14 05:12:44.000000000 +0200 +++ new/csvkit-1.1.1/csvkit/utilities/csvstack.py 2023-02-22 19:22:00.000000000 +0100 @@ -8,9 +8,20 @@ from csvkit.cli import CSVKitUtility, isatty, make_default_headers +def _skip_lines(f, args): + if isinstance(args.skip_lines, int): + skip_lines = args.skip_lines + while skip_lines > 0: + f.readline() + skip_lines -= 1 + else: + raise ValueError('skip_lines argument must be an int') + + return skip_lines + + class CSVStack(CSVKitUtility): - description = 'Stack up the rows from multiple CSV files, optionally adding a grouping value. Files are assumed ' \ - 'to have the same columns in the same order.' + description = 'Stack up the rows from multiple CSV files, optionally adding a grouping value.' # Override 'f' because the utility accepts multiple files. override_flags = ['f', 'L', 'blanks', 'date-format', 'datetime-format'] @@ -45,57 +56,88 @@ groups = None group_name = self.args.group_name if self.args.group_name else 'group' + use_fieldnames = not self.args.no_header_row + + if use_fieldnames: + Reader = agate.csv.DictReader + else: + Reader = agate.csv.reader - output = agate.csv.writer(self.output_file, **self.writer_kwargs) + headers = [] + stdin_fieldnames = [] + stdin_first_row = [] - for i, path in enumerate(self.args.input_paths): + for path in self.args.input_paths: f = self._open_input_file(path) + file_is_stdin = path == '-' - if isinstance(self.args.skip_lines, int): - skip_lines = self.args.skip_lines - while skip_lines > 0: - f.readline() - skip_lines -= 1 - else: - raise ValueError('skip_lines argument must be an int') - - rows = agate.csv.reader(f, **self.reader_kwargs) + _skip_lines(f, self.args) + rows = Reader(f, **self.reader_kwargs) - if has_groups: - if groups: - group = groups[i] + if use_fieldnames: + for field in rows.fieldnames: + if field not in headers: + headers.append(field) + + # If the file is standard input, store the fieldnames so that the rows can be read correctly later. + if file_is_stdin: + stdin_fieldnames = rows.fieldnames else: - group = os.path.basename(f.name) - - # If we have header rows, use them - if not self.args.no_header_row: - headers = next(rows, []) - - if i == 0: - if has_groups: - headers.insert(0, group_name) - - output.writerow(headers) - # If we don't generate simple column names based on first row + f.close() else: row = next(rows, []) - headers = list(make_default_headers(len(row))) - if i == 0: - if has_groups: - headers.insert(0, group_name) + # If the file is standard input, store the row that was used to calculate the number of columns. + if file_is_stdin: + stdin_first_row = row + else: + f.close() - output.writerow(headers) + # If we aren't using header rows, we only look at the first file and stack columns in the same order. + break - if has_groups: - row.insert(0, group) + if has_groups: + headers.insert(0, group_name) - output.writerow(row) + if use_fieldnames: + output = agate.csv.DictWriter(self.output_file, fieldnames=headers, **self.writer_kwargs) + output.writeheader() + else: + output = agate.csv.writer(self.output_file, **self.writer_kwargs) + output.writerow(headers) + + for i, path in enumerate(self.args.input_paths): + f = self._open_input_file(path) + file_is_stdin = path == '-' + + if has_groups: + if groups: + group = groups[i] + else: + group = os.path.basename(f.name) + + # If the file is standard input, we've already skipped any lines above, to find its header row. + if not file_is_stdin: + _skip_lines(f, self.args) + + # If the file is standard input, we've already read the header row, so we need to provide it here. + kwargs = {} + if file_is_stdin and use_fieldnames: + kwargs['fieldnames'] = stdin_fieldnames + + rows = Reader(f, **self.reader_kwargs, **kwargs) + + # If the file is standard input, we need to add back the row we used to calculate the number of columns. + if file_is_stdin and stdin_first_row: + output.writerow(stdin_first_row) for row in rows: if has_groups: - row.insert(0, group) + if use_fieldnames: + row[group_name] = group + else: + row.insert(0, group) output.writerow(row) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/csvkit/utilities/csvstat.py new/csvkit-1.1.1/csvkit/utilities/csvstat.py --- old/csvkit-1.1.0/csvkit/utilities/csvstat.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/csvkit/utilities/csvstat.py 2023-01-06 21:32:15.000000000 +0100 @@ -223,7 +223,7 @@ # Formatting if op_name == 'freq': - stat = ', '.join([('"%s": %s' % (str(row['value']), row['count'])) for row in stat]) + stat = ', '.join([('"{}": {}'.format(str(row['value']), row['count'])) for row in stat]) stat = '{ %s }' % stat if label: @@ -270,7 +270,7 @@ column = table.columns[column_id] column_stats = stats[column_id] - self.output_file.write(('%3i. "%s"\n\n' % (column_id + 1, column_name))) + self.output_file.write('%3i. "%s"\n\n' % (column_id + 1, column_name)) for op_name, op_data in OPERATIONS.items(): if column_stats[op_name] is None: @@ -284,7 +284,7 @@ if op_name == 'freq': for i, row in enumerate(column_stats['freq']): if i == 0: - self.output_file.write('\t{} '.format(label)) + self.output_file.write(f'\t{label} ') else: self.output_file.write('\t{label:{label_column_width}} '.format(**{ 'label_column_width': label_column_width, @@ -310,7 +310,7 @@ elif op_name == 'len': v = '%s characters' % v - self.output_file.write('\t{} {}\n'.format(label, v)) + self.output_file.write(f'\t{label} {v}\n') self.output_file.write('\n') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/csvkit.egg-info/PKG-INFO new/csvkit-1.1.1/csvkit.egg-info/PKG-INFO --- old/csvkit-1.1.0/csvkit.egg-info/PKG-INFO 2023-01-03 19:21:05.000000000 +0100 +++ new/csvkit-1.1.1/csvkit.egg-info/PKG-INFO 2023-02-22 19:26:23.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: csvkit -Version: 1.1.0 +Version: 1.1.1 Summary: A suite of command-line tools for working with CSV, the king of tabular file formats. Home-page: https://github.com/wireservice/csvkit Author: Christopher Groskopf diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/csvkit.egg-info/SOURCES.txt new/csvkit-1.1.1/csvkit.egg-info/SOURCES.txt --- old/csvkit-1.1.0/csvkit.egg-info/SOURCES.txt 2023-01-03 19:21:05.000000000 +0100 +++ new/csvkit-1.1.1/csvkit.egg-info/SOURCES.txt 2023-02-22 19:26:23.000000000 +0100 @@ -77,6 +77,8 @@ examples/dummy.xlsx examples/dummy2.csv examples/dummy3.csv +examples/dummy_col_shuffled.csv +examples/dummy_col_shuffled_ragged.csv examples/empty.csv examples/foo1.csv examples/foo2.csv diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/docs/conf.py new/csvkit-1.1.1/docs/conf.py --- old/csvkit-1.1.0/docs/conf.py 2023-01-03 19:18:26.000000000 +0100 +++ new/csvkit-1.1.1/docs/conf.py 2023-02-22 19:25:19.000000000 +0100 @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # csvkit documentation build configuration file, created by # sphinx-quickstart on Fri Apr 15 21:52:09 2011. @@ -41,7 +40,7 @@ # built documents. # # The short X.Y version. -version = '1.1.0' +version = '1.1.1' # The full version, including alpha/beta/rc tags. release = version diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/docs/scripts/csvstack.rst new/csvkit-1.1.1/docs/scripts/csvstack.rst --- old/csvkit-1.1.0/docs/scripts/csvstack.rst 2022-03-07 00:09:01.000000000 +0100 +++ new/csvkit-1.1.1/docs/scripts/csvstack.rst 2023-02-22 19:22:00.000000000 +0100 @@ -14,7 +14,6 @@ FILE [FILE ...] Stack up the rows from multiple CSV files, optionally adding a grouping value. - Files are assumed to have the same columns in the same order. positional arguments: FILE The CSV file(s) to operate on. If omitted, will accept @@ -42,14 +41,10 @@ Examples ======== -Joining a set of homogeneous files for different years:: +Joining a set of files for different years:: csvstack -g 2009,2010 examples/realdata/FY09_EDU_Recipients_by_State.csv examples/realdata/Datagov_FY10_EDU_recp_by_State.csv -Joining files with the same columns but in different orders, in Bash, assuming the header row does not contain newlines:: - - csvstack file1.csv <(csvcut -c `head -1 file1.csv` file2.csv) - Add a single column to the left of a CSV:: csvstack -n NEWCOL -g "" examples/dummy.csv diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/examples/dummy_col_shuffled.csv new/csvkit-1.1.1/examples/dummy_col_shuffled.csv --- old/csvkit-1.1.0/examples/dummy_col_shuffled.csv 1970-01-01 01:00:00.000000000 +0100 +++ new/csvkit-1.1.1/examples/dummy_col_shuffled.csv 2023-02-22 19:22:00.000000000 +0100 @@ -0,0 +1,2 @@ +b,c,a +2,3,1 \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/examples/dummy_col_shuffled_ragged.csv new/csvkit-1.1.1/examples/dummy_col_shuffled_ragged.csv --- old/csvkit-1.1.0/examples/dummy_col_shuffled_ragged.csv 1970-01-01 01:00:00.000000000 +0100 +++ new/csvkit-1.1.1/examples/dummy_col_shuffled_ragged.csv 2023-02-22 19:22:00.000000000 +0100 @@ -0,0 +1,2 @@ +b,c,a,d +2,3,1,4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/setup.py new/csvkit-1.1.1/setup.py --- old/csvkit-1.1.0/setup.py 2023-01-03 19:18:21.000000000 +0100 +++ new/csvkit-1.1.1/setup.py 2023-02-22 19:25:03.000000000 +0100 @@ -5,7 +5,7 @@ setup( name='csvkit', - version='1.1.0', + version='1.1.1', description='A suite of command-line tools for working with CSV, the king of tabular file formats.', long_description=long_description, long_description_content_type='text/x-rst', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_convert/test_fixed.py new/csvkit-1.1.1/tests/test_convert/test_fixed.py --- old/csvkit-1.1.0/tests/test_convert/test_fixed.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_convert/test_fixed.py 2023-01-06 21:32:15.000000000 +0100 @@ -11,19 +11,19 @@ Utility = In2CSV def test_fixed(self): - with open('examples/testfixed', 'r') as f: - with open('examples/testfixed_schema.csv', 'r') as schema: + with open('examples/testfixed') as f: + with open('examples/testfixed_schema.csv') as schema: output = fixed.fixed2csv(f, schema) - with open('examples/testfixed_converted.csv', 'r') as f: + with open('examples/testfixed_converted.csv') as f: self.assertEqual(f.read(), output) def test_fixed_skip_lines(self): - with open('examples/testfixed_skip_lines', 'r') as f: - with open('examples/testfixed_schema.csv', 'r') as schema: + with open('examples/testfixed_skip_lines') as f: + with open('examples/testfixed_schema.csv') as schema: output = fixed.fixed2csv(f, schema, skip_lines=3) - with open('examples/testfixed_converted.csv', 'r') as f: + with open('examples/testfixed_converted.csv') as f: self.assertEqual(f.read(), output) def test_fixed_no_inference(self): @@ -39,14 +39,14 @@ input_file.close() def test_fixed_streaming(self): - with open('examples/testfixed', 'r') as f: - with open('examples/testfixed_schema.csv', 'r') as schema: + with open('examples/testfixed') as f: + with open('examples/testfixed_schema.csv') as schema: output_file = StringIO() fixed.fixed2csv(f, schema, output=output_file) output = output_file.getvalue() output_file.close() - with open('examples/testfixed_converted.csv', 'r') as f: + with open('examples/testfixed_converted.csv') as f: self.assertEqual(f.read(), output) def test_schema_decoder_init(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_utilities/test_csvclean.py new/csvkit-1.1.1/tests/test_utilities/test_csvclean.py --- old/csvkit-1.1.0/tests/test_utilities/test_csvclean.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_utilities/test_csvclean.py 2023-01-06 21:32:15.000000000 +0100 @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import os import sys diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_utilities/test_csvcut.py new/csvkit-1.1.1/tests/test_utilities/test_csvcut.py --- old/csvkit-1.1.0/tests/test_utilities/test_csvcut.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_utilities/test_csvcut.py 2023-01-06 21:32:15.000000000 +0100 @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import sys from unittest.mock import patch diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_utilities/test_csvformat.py new/csvkit-1.1.1/tests/test_utilities/test_csvformat.py --- old/csvkit-1.1.0/tests/test_utilities/test_csvformat.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_utilities/test_csvformat.py 2023-01-06 21:32:15.000000000 +0100 @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import sys from io import StringIO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_utilities/test_csvgrep.py new/csvkit-1.1.1/tests/test_utilities/test_csvgrep.py --- old/csvkit-1.1.0/tests/test_utilities/test_csvgrep.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_utilities/test_csvgrep.py 2023-01-06 21:32:15.000000000 +0100 @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import sys from unittest.mock import patch diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_utilities/test_csvjson.py new/csvkit-1.1.1/tests/test_utilities/test_csvjson.py --- old/csvkit-1.1.0/tests/test_utilities/test_csvjson.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_utilities/test_csvjson.py 2023-01-06 21:32:15.000000000 +0100 @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import json import sys diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_utilities/test_csvlook.py new/csvkit-1.1.1/tests/test_utilities/test_csvlook.py --- old/csvkit-1.1.0/tests/test_utilities/test_csvlook.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_utilities/test_csvlook.py 2023-01-06 21:32:15.000000000 +0100 @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import sys from io import StringIO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_utilities/test_csvsort.py new/csvkit-1.1.1/tests/test_utilities/test_csvsort.py --- old/csvkit-1.1.0/tests/test_utilities/test_csvsort.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_utilities/test_csvsort.py 2023-01-06 21:32:15.000000000 +0100 @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import sys from io import StringIO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_utilities/test_csvsql.py new/csvkit-1.1.1/tests/test_utilities/test_csvsql.py --- old/csvkit-1.1.0/tests/test_utilities/test_csvsql.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_utilities/test_csvsql.py 2023-01-06 21:32:15.000000000 +0100 @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import os import sys diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_utilities/test_csvstack.py new/csvkit-1.1.1/tests/test_utilities/test_csvstack.py --- old/csvkit-1.1.0/tests/test_utilities/test_csvstack.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_utilities/test_csvstack.py 2023-02-22 19:22:00.000000000 +0100 @@ -4,7 +4,7 @@ from unittest.mock import patch from csvkit.utilities.csvstack import CSVStack, launch_new_instance -from tests.utils import CSVKitTestCase, EmptyFileTests +from tests.utils import CSVKitTestCase, EmptyFileTests, stdin_as_string class TestCSVStack(CSVKitTestCase, EmptyFileTests): @@ -22,6 +22,15 @@ ['1', '2', '3'], ]) + def test_skip_lines_stdin(self): + with open('examples/test_skip_lines.csv') as f: + with stdin_as_string(f): + self.assertRows(['--skip-lines', '3', '-', 'examples/test_skip_lines.csv'], [ + ['a', 'b', 'c'], + ['1', '2', '3'], + ['1', '2', '3'], + ]) + def test_single_file_stack(self): self.assertRows(['examples/dummy.csv'], [ ['a', 'b', 'c'], @@ -35,6 +44,43 @@ ['1', '2', '3'], ]) + def test_multiple_file_stack_col(self): + self.assertRows(['examples/dummy.csv', 'examples/dummy_col_shuffled.csv'], [ + ['a', 'b', 'c'], + ['1', '2', '3'], + ['1', '2', '3'], + ]) + + self.assertRows(['examples/dummy_col_shuffled.csv', 'examples/dummy.csv'], [ + ['b', 'c', 'a'], + ['2', '3', '1'], + ['2', '3', '1'], + ]) + + def test_multiple_file_stack_col_ragged(self): + self.assertRows(['examples/dummy.csv', 'examples/dummy_col_shuffled_ragged.csv'], [ + ['a', 'b', 'c', 'd'], + ['1', '2', '3', ''], + ['1', '2', '3', '4'], + ]) + + def test_multiple_file_stack_col_ragged_stdin(self): + with open('examples/dummy.csv') as f: + with stdin_as_string(f): + self.assertRows(['-', 'examples/dummy_col_shuffled_ragged.csv'], [ + ['a', 'b', 'c', 'd'], + ['1', '2', '3', ''], + ['1', '2', '3', '4'], + ]) + + with open('examples/dummy.csv') as f: + with stdin_as_string(f): + self.assertRows(['examples/dummy_col_shuffled_ragged.csv', '-'], [ + ['b', 'c', 'a', 'd'], + ['2', '3', '1', '4'], + ['2', '3', '1', ''], + ]) + def test_explicit_grouping(self): self.assertRows(['--groups', 'asd,sdf', '-n', 'foo', 'examples/dummy.csv', 'examples/dummy2.csv'], [ ['foo', 'a', 'b', 'c'], @@ -59,6 +105,23 @@ ['4', '5', '6'], ]) + def test_no_header_row_basic_stdin(self): + with open('examples/no_header_row.csv') as f: + with stdin_as_string(f): + self.assertRows(['--no-header-row', '-', 'examples/no_header_row2.csv'], [ + ['a', 'b', 'c'], + ['1', '2', '3'], + ['4', '5', '6'], + ]) + + with open('examples/no_header_row.csv') as f: + with stdin_as_string(f): + self.assertRows(['--no-header-row', 'examples/no_header_row2.csv', '-'], [ + ['a', 'b', 'c'], + ['4', '5', '6'], + ['1', '2', '3'], + ]) + def test_grouped_manual_and_named_column(self): self.assertRows( [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_utilities/test_in2csv.py new/csvkit-1.1.1/tests/test_utilities/test_in2csv.py --- old/csvkit-1.1.0/tests/test_utilities/test_in2csv.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_utilities/test_in2csv.py 2023-01-06 21:32:15.000000000 +0100 @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import os import sys @@ -17,7 +16,7 @@ def assertConverted(self, input_format, input_filename, output_filename, additional_args=[]): output = self.get_output(['-f', input_format, input_filename] + additional_args) - with open(output_filename, 'r') as f: + with open(output_filename) as f: self.assertEqual(output, f.read()) def test_launch_new_instance(self): @@ -213,11 +212,11 @@ try: self.assertConverted('xls', 'examples/sheets.xls', 'examples/testxls_converted.csv', ['--sheet', 'data', '--write-sheets', "ʤ,1"]) - with open('examples/sheets_0.csv', 'r') as f: - with open('examples/testxls_unicode_converted.csv', 'r') as g: + with open('examples/sheets_0.csv') as f: + with open('examples/testxls_unicode_converted.csv') as g: self.assertEqual(f.read(), g.read()) - with open('examples/sheets_1.csv', 'r') as f: - with open('examples/testxls_converted.csv', 'r') as g: + with open('examples/sheets_1.csv') as f: + with open('examples/testxls_converted.csv') as g: self.assertEqual(f.read(), g.read()) self.assertFalse(os.path.exists('examples/sheets_2.csv')) finally: @@ -230,11 +229,11 @@ try: self.assertConverted('xlsx', 'examples/sheets.xlsx', 'examples/testxlsx_noinference_converted.csv', ['--no-inference', '--sheet', 'data', '--write-sheets', "ʤ,1"]) - with open('examples/sheets_0.csv', 'r') as f: - with open('examples/testxlsx_unicode_converted.csv', 'r') as g: + with open('examples/sheets_0.csv') as f: + with open('examples/testxlsx_unicode_converted.csv') as g: self.assertEqual(f.read(), g.read()) - with open('examples/sheets_1.csv', 'r') as f: - with open('examples/testxlsx_noinference_converted.csv', 'r') as g: + with open('examples/sheets_1.csv') as f: + with open('examples/testxlsx_noinference_converted.csv') as g: self.assertEqual(f.read(), g.read()) self.assertFalse(os.path.exists('examples/sheets_2.csv')) finally: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/csvkit-1.1.0/tests/test_utilities/test_sql2csv.py new/csvkit-1.1.1/tests/test_utilities/test_sql2csv.py --- old/csvkit-1.1.0/tests/test_utilities/test_sql2csv.py 2022-12-21 00:39:08.000000000 +0100 +++ new/csvkit-1.1.1/tests/test_utilities/test_sql2csv.py 2023-01-06 21:32:15.000000000 +0100 @@ -45,7 +45,7 @@ utility = CSVSQL(args) utility.run() - with open(csv_file, 'r') as f: + with open(csv_file) as f: text = f.read() return text.strip()
