Skip to content

Commit d2668bd

Browse files
authored
Merge pull request astanin#51 from djw8605/decimal-align-commas
Recognize numbers with comma separators
2 parents b4e5a14 + 5fb1fcd commit d2668bd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tabulate.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,16 @@ def _isnumber(string):
595595
False
596596
>>> _isnumber("inf")
597597
True
598+
>>> _isnumber("1,234.56")
599+
True
600+
>>> _isnumber("1,234,578.0")
601+
True
598602
"""
599-
if not _isconvertible(float, string):
603+
if isinstance(string, (_text_type)) and "," in string and (
604+
_isconvertible(float, string.replace(",",""))
605+
):
606+
return True
607+
elif not _isconvertible(float, string):
600608
return False
601609
elif isinstance(string, (_text_type, _binary_type)) and (
602610
math.isinf(float(string)) or math.isnan(float(string))

0 commit comments

Comments
 (0)