Skip to content

Commit

Permalink
csvstat: Add a "Most decimal places" statistic and --max-precision op…
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Oct 17, 2023
1 parent 54857aa commit cc3dabb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Unreleased
* :doc:`/scripts/csvstat` adds a :code:`--json` option to output results as JSON text.
* :doc:`/scripts/csvstat` adds an :code:`--indent` option to indent the JSON text when :code:`--json` is set.
* :doc:`/scripts/csvstat` reports a "Non-null values" statistic (or a :code:`nonnulls` column when :code:`--csv` is set).
* :doc:`/scripts/csvstat` reports a "Most decimal places" statistic (or a :code:`maxprecision` column when :code:`--csv` is set).
* :doc:`/scripts/csvstat` adds a :code:`--non-nulls` option to only output counts of non-null values.
* :doc:`/scripts/csvstat` adds a :code:`--max-precision` option to only output the most decimal places.
* feat: Add a :code:`--null-value` option to commands with the :code:`--blanks` option, to convert additional values to NULL.
* Add Python 3.12 support.

Expand Down
7 changes: 7 additions & 0 deletions csvkit/utilities/csvstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
'aggregation': agate.MaxLength,
'label': 'Longest value: ',
}),
('maxprecision', {
'aggregation': agate.MaxPrecision,
'label': 'Most decimal places: ',
}),
('freq', {
'aggregation': None,
'label': 'Most common values: ',
Expand Down Expand Up @@ -117,6 +121,9 @@ def add_arguments(self):
self.argparser.add_argument(
'--len', dest='len_only', action='store_true',
help='Only output the length of the longest values.')
self.argparser.add_argument(
'--max-precision', dest='maxprecision_only', action='store_true',
help='Only output the most decimal places.')
self.argparser.add_argument(
'--freq', dest='freq_only', action='store_true',
help='Only output lists of frequent values.')
Expand Down

0 comments on commit cc3dabb

Please sign in to comment.