Skip to content

Commit

Permalink
feat(csvsql): Add --min-col-len and --col-len-multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jul 12, 2024
1 parent 5d7ea14 commit 60fa3cf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ Unreleased
----------

- feat: Add man pages.
- feat: :doc:`/scripts/csvsql` adds the options:

- :code:`--min-col-len`
- :code:`--col-len-multiplier`

- fix: :doc:`/scripts/csvstat` no longer errors when a column is a time delta and :code:`--json` is set.

2.0.0 - May 1, 2024
Expand Down
8 changes: 8 additions & 0 deletions csvkit/utilities/csvsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def add_arguments(self):
self.argparser.add_argument(
'--chunk-size', dest='chunk_size', type=int,
help='Chunk size for batch insert into the table. Requires --insert.')
self.argparser.add_argument(
'--min-col-len', dest='min_col_len', type=int,
help='The minimum length of text columns.')
self.argparser.add_argument(
'--col-len-multiplier', dest='col_len_multiplier', type=int,
help='Multiply the maximum column length by this multiplier to accomodate larger values in later runs.')

def main(self):
if isatty(sys.stdin) and self.args.input_paths == ['-']:
Expand Down Expand Up @@ -206,6 +212,8 @@ def _failsafe_main(self):
constraints=not self.args.no_constraints,
unique_constraint=self.unique_constraint,
chunk_size=self.args.chunk_size,
min_col_len=self.args.min_col_len,
col_len_multiplier=self.args.col_len_multiplier,
)

if self.args.after_insert:
Expand Down
5 changes: 5 additions & 0 deletions docs/scripts/csvsql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ Generate SQL statements for a CSV file or execute those statements directly on a
--chunk-size CHUNK_SIZE
Chunk size for batch insert into the table. Requires
--insert.
--min-col-len MIN_COL_LEN
The minimum length of text columns.
--col-len-multiplier COL_LEN_MULTIPLIER
Multiply the maximum column length by this multiplier
to accomodate larger values in later runs.
See also: :doc:`../common_arguments`.

Expand Down
5 changes: 5 additions & 0 deletions man/csvsql.1
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ optional arguments:
\-\-chunk\-size CHUNK_SIZE
Chunk size for batch insert into the table. Requires
\-\-insert.
\-\-min\-col\-len MIN_COL_LEN
The minimum length of text columns.
\-\-col\-len\-multiplier COL_LEN_MULTIPLIER
Multiply the maximum column length by this multiplier
to accomodate larger values in later runs.
.ft P
.fi
.UNINDENT
Expand Down

0 comments on commit 60fa3cf

Please sign in to comment.