@@ -1642,6 +1642,12 @@ def __init__(self, f, **kwds):
1642
1642
if len (self .decimal ) != 1 :
1643
1643
raise ValueError ('Only length-1 decimal markers supported' )
1644
1644
1645
+ if self .thousands is None :
1646
+ self .nonnum = re .compile ('[^-^0-9^%s]+' % self .decimal )
1647
+ else :
1648
+ self .nonnum = re .compile ('[^-^0-9^%s^%s]+' % (self .thousands ,
1649
+ self .decimal ))
1650
+
1645
1651
def _set_no_thousands_columns (self ):
1646
1652
# Create a set of column ids that are not to be stripped of thousands
1647
1653
# operators.
@@ -2053,13 +2059,12 @@ def _check_empty(self, lines):
2053
2059
def _check_thousands (self , lines ):
2054
2060
if self .thousands is None :
2055
2061
return lines
2056
- nonnum = re . compile ( '[^-^0-9^%s^%s]+' % ( self . thousands , self . decimal ))
2062
+
2057
2063
return self ._search_replace_num_columns (lines = lines ,
2058
2064
search = self .thousands ,
2059
- replace = '' ,
2060
- nonnum = nonnum )
2065
+ replace = '' )
2061
2066
2062
- def _search_replace_num_columns (self , lines , search , replace , nonnum ):
2067
+ def _search_replace_num_columns (self , lines , search , replace ):
2063
2068
ret = []
2064
2069
for l in lines :
2065
2070
rl = []
@@ -2068,26 +2073,20 @@ def _search_replace_num_columns(self, lines, search, replace, nonnum):
2068
2073
search not in x or
2069
2074
(self ._no_thousands_columns and
2070
2075
i in self ._no_thousands_columns ) or
2071
- nonnum .search (x .strip ())):
2076
+ self . nonnum .search (x .strip ())):
2072
2077
rl .append (x )
2073
2078
else :
2074
2079
rl .append (x .replace (search , replace ))
2075
2080
ret .append (rl )
2076
2081
return ret
2077
2082
2078
2083
def _check_decimal (self , lines ):
2079
- if self .decimal == b'.' :
2084
+ if self .decimal == _parser_defaults [ 'decimal' ] :
2080
2085
return lines
2081
2086
2082
- if self .thousands is None :
2083
- nonnum = re .compile ('[^-^0-9^%s]+' % self .decimal )
2084
- else :
2085
- nonnum = re .compile ('[^-^0-9^%s^%s]+' % (self .thousands ,
2086
- self .decimal ))
2087
2087
return self ._search_replace_num_columns (lines = lines ,
2088
2088
search = self .decimal ,
2089
- replace = '.' ,
2090
- nonnum = nonnum )
2089
+ replace = '.' )
2091
2090
2092
2091
def _clear_buffer (self ):
2093
2092
self .buf = []
0 commit comments