diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b24a7937..7ab1a95b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,8 @@ +Unreleased +---------- + +- 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 ------------------- diff --git a/csvkit/cli.py b/csvkit/cli.py index a0d54c26..7d3554c4 100644 --- a/csvkit/cli.py +++ b/csvkit/cli.py @@ -444,6 +444,8 @@ def default_str_decimal(obj): def default_float_decimal(obj): + if isinstance(obj, datetime.timedelta): + return obj.total_seconds() if isinstance(obj, decimal.Decimal): return float(obj) return default_str_decimal(obj)