@@ -637,19 +637,19 @@ cdef class TextReader:
637
637
source = zip_file.open(file_name)
638
638
639
639
elif len (zip_names) == 0 :
640
- raise ValueError (' Zero files found in compressed '
641
- ' zip file %s ' , source)
640
+ raise ValueError (f ' Zero files found in compressed '
641
+ f ' zip file { source} ' )
642
642
else :
643
- raise ValueError (' Multiple files found in compressed '
644
- ' zip file %s ' , str ( zip_names) )
643
+ raise ValueError (f ' Multiple files found in compressed '
644
+ f ' zip file { zip_names} ' )
645
645
elif self .compression == ' xz' :
646
646
if isinstance (source, str ):
647
647
source = _get_lzma_file(lzma)(source, ' rb' )
648
648
else :
649
649
source = _get_lzma_file(lzma)(filename = source)
650
650
else :
651
- raise ValueError (' Unrecognized compression type: %s ' %
652
- self .compression)
651
+ raise ValueError (f ' Unrecognized compression type: '
652
+ f ' { self.compression} ' )
653
653
654
654
if b' utf-16' in (self .encoding or b' ' ):
655
655
# we need to read utf-16 through UTF8Recoder.
@@ -703,8 +703,8 @@ cdef class TextReader:
703
703
self .parser.cb_io = & buffer_rd_bytes
704
704
self .parser.cb_cleanup = & del_rd_source
705
705
else :
706
- raise IOError (' Expected file path name or file-like object,'
707
- ' got %s type' % type (source))
706
+ raise IOError (f ' Expected file path name or file-like object, '
707
+ f ' got { type(source)} type ' )
708
708
709
709
cdef _get_header(self ):
710
710
# header is now a list of lists, so field_count should use header[0]
@@ -744,8 +744,8 @@ cdef class TextReader:
744
744
msg = " [%s ], len of %d ," % (
745
745
' ,' .join(str (m) for m in msg), len (msg))
746
746
raise ParserError(
747
- ' Passed header=%s but only %d lines in file '
748
- % (msg, self .parser.lines) )
747
+ f ' Passed header={msg} but only '
748
+ f ' { self.parser.lines} lines in file ' )
749
749
750
750
else :
751
751
field_count = self .parser.line_fields[hr]
@@ -779,7 +779,7 @@ cdef class TextReader:
779
779
if not self .has_mi_columns and self .mangle_dupe_cols:
780
780
while count > 0 :
781
781
counts[name] = count + 1
782
- name = ' %s . %d ' % ( name, count)
782
+ name = f ' { name}.{ count} '
783
783
count = counts.get(name, 0 )
784
784
785
785
if old_name == ' ' :
@@ -1662,7 +1662,7 @@ cdef _to_fw_string(parser_t *parser, int64_t col, int64_t line_start,
1662
1662
char * data
1663
1663
ndarray result
1664
1664
1665
- result = np.empty(line_end - line_start, dtype = ' |S%d ' % width)
1665
+ result = np.empty(line_end - line_start, dtype = f ' |S{ width} ' )
1666
1666
data = < char * > result.data
1667
1667
1668
1668
with nogil:
@@ -2176,8 +2176,8 @@ def _concatenate_chunks(list chunks):
2176
2176
if warning_columns:
2177
2177
warning_names = ' ,' .join(warning_columns)
2178
2178
warning_message = " " .join([
2179
- " Columns (%s ) have mixed types." % warning_names,
2180
- " Specify dtype option on import or set low_memory=False."
2179
+ f " Columns ({warning_names} ) have mixed types."
2180
+ f " Specify dtype option on import or set low_memory=False."
2181
2181
])
2182
2182
warnings.warn(warning_message, DtypeWarning, stacklevel = 8 )
2183
2183
return result
0 commit comments