@@ -29,7 +29,7 @@ cdef extern from "Python.h":
29
29
30
30
import numpy as np
31
31
cimport numpy as cnp
32
- from numpy cimport ndarray, uint8_t, uint64_t, int64_t
32
+ from numpy cimport ndarray, uint8_t, uint64_t, int64_t, float64_t
33
33
cnp.import_array()
34
34
35
35
from util cimport UINT64_MAX, INT64_MAX, INT64_MIN
@@ -694,7 +694,7 @@ cdef class TextReader:
694
694
if ptr == NULL :
695
695
if not os.path.exists(source):
696
696
raise compat.FileNotFoundError(
697
- ' File %s does not exist' % source)
697
+ ' File {source} does not exist' .format( source = source) )
698
698
raise IOError (' Initializing from file failed' )
699
699
700
700
self .parser.source = ptr
@@ -772,9 +772,10 @@ cdef class TextReader:
772
772
773
773
if name == ' ' :
774
774
if self .has_mi_columns:
775
- name = ' Unnamed: %d _level_%d ' % (i, level)
775
+ name = (' Unnamed: {i}_level_{lvl}'
776
+ .format(i = i, lvl = level))
776
777
else :
777
- name = ' Unnamed: %d ' % i
778
+ name = ' Unnamed: {i} ' .format( i = i)
778
779
unnamed_count += 1
779
780
780
781
count = counts.get(name, 0 )
@@ -849,8 +850,8 @@ cdef class TextReader:
849
850
# 'data has %d fields'
850
851
# % (passed_count, field_count))
851
852
852
- if self .has_usecols and self .allow_leading_cols and \
853
- not callable (self .usecols):
853
+ if ( self .has_usecols and self .allow_leading_cols and
854
+ not callable (self .usecols)) :
854
855
nuse = len (self .usecols)
855
856
if nuse == passed_count:
856
857
self .leading_cols = 0
@@ -1027,17 +1028,19 @@ cdef class TextReader:
1027
1028
1028
1029
if self .table_width - self .leading_cols > num_cols:
1029
1030
raise ParserError(
1030
- " Too many columns specified: expected %s and found %s " %
1031
- (self .table_width - self .leading_cols, num_cols))
1031
+ " Too many columns specified: expected {expected} and "
1032
+ " found {found}"
1033
+ .format(expected = self .table_width - self .leading_cols,
1034
+ found = num_cols))
1032
1035
1033
1036
results = {}
1034
1037
nused = 0
1035
1038
for i in range (self .table_width):
1036
1039
if i < self .leading_cols:
1037
1040
# Pass through leading columns always
1038
1041
name = i
1039
- elif self .usecols and not callable (self .usecols) and \
1040
- nused == len (self .usecols):
1042
+ elif ( self .usecols and not callable (self .usecols) and
1043
+ nused == len (self .usecols)) :
1041
1044
# Once we've gathered all requested columns, stop. GH5766
1042
1045
break
1043
1046
else :
@@ -1103,7 +1106,7 @@ cdef class TextReader:
1103
1106
col_res = _maybe_upcast(col_res)
1104
1107
1105
1108
if col_res is None :
1106
- raise ParserError(' Unable to parse column %d ' % i )
1109
+ raise ParserError(' Unable to parse column {i} ' .format( i = i) )
1107
1110
1108
1111
results[i] = col_res
1109
1112
@@ -1222,8 +1225,8 @@ cdef class TextReader:
1222
1225
elif dtype.kind == ' U' :
1223
1226
width = dtype.itemsize
1224
1227
if width > 0 :
1225
- raise TypeError (" the dtype %s is not "
1226
- " supported for parsing" % dtype)
1228
+ raise TypeError (" the dtype {dtype} is not "
1229
+ " supported for parsing" .format( dtype = dtype) )
1227
1230
1228
1231
# unicode variable width
1229
1232
return self ._string_convert(i, start, end, na_filter,
@@ -1241,12 +1244,12 @@ cdef class TextReader:
1241
1244
return self ._string_convert(i, start, end, na_filter,
1242
1245
na_hashset)
1243
1246
elif is_datetime64_dtype(dtype):
1244
- raise TypeError (" the dtype %s is not supported "
1247
+ raise TypeError (" the dtype {dtype} is not supported "
1245
1248
" for parsing, pass this column "
1246
- " using parse_dates instead" % dtype)
1249
+ " using parse_dates instead" .format( dtype = dtype) )
1247
1250
else :
1248
- raise TypeError (" the dtype %s is not "
1249
- " supported for parsing" % dtype)
1251
+ raise TypeError (" the dtype {dtype} is not "
1252
+ " supported for parsing" .format( dtype = dtype) )
1250
1253
1251
1254
cdef _string_convert(self , Py_ssize_t i, int64_t start, int64_t end,
1252
1255
bint na_filter, kh_str_t * na_hashset):
@@ -2058,7 +2061,7 @@ cdef kh_float64_t* kset_float64_from_list(values) except NULL:
2058
2061
khiter_t k
2059
2062
kh_float64_t * table
2060
2063
int ret = 0
2061
- cnp. float64_t val
2064
+ float64_t val
2062
2065
object value
2063
2066
2064
2067
table = kh_init_float64()
@@ -2101,7 +2104,7 @@ cdef raise_parser_error(object base, parser_t *parser):
2101
2104
Py_XDECREF(type )
2102
2105
raise old_exc
2103
2106
2104
- message = ' %s . C error: ' % base
2107
+ message = ' {base} . C error: ' .format( base = base)
2105
2108
if parser.error_msg != NULL :
2106
2109
if PY3:
2107
2110
message += parser.error_msg.decode(' utf-8' )
0 commit comments