@@ -354,23 +354,24 @@ class DataTable:
354
354
355
355
def __init__ (
356
356
self , filenameOrHeadings = None , delimiter = ',' ,
357
- allowComments = True , stripWhite = True ,
357
+ allowComments = True , stripWhite = True , encoding = None ,
358
358
defaultType = None , usePickleCache = None ):
359
359
if usePickleCache is None :
360
360
self ._usePickleCache = self ._usePickleCache
361
361
else :
362
362
self ._usePickleCache = usePickleCache
363
363
if defaultType and defaultType not in _types :
364
364
raise DataTableError (
365
- 'Unknown type for default type: %r' % defaultType )
365
+ f 'Unknown type for default type: { defaultType !r } ' )
366
366
self ._defaultType = defaultType
367
367
self ._filename = None
368
368
self ._headings = []
369
369
self ._rows = []
370
370
if filenameOrHeadings :
371
371
if isinstance (filenameOrHeadings , str ):
372
372
self .readFileNamed (
373
- filenameOrHeadings , delimiter , allowComments , stripWhite )
373
+ filenameOrHeadings , delimiter ,
374
+ allowComments , stripWhite , encoding )
374
375
else :
375
376
self .setHeadings (filenameOrHeadings )
376
377
@@ -380,7 +381,8 @@ def __init__(
380
381
381
382
def readFileNamed (
382
383
self , filename , delimiter = ',' ,
383
- allowComments = True , stripWhite = True , worksheet = 1 , row = 1 , column = 1 ):
384
+ allowComments = True , stripWhite = True , encoding = None ,
385
+ worksheet = 1 , row = 1 , column = 1 ):
384
386
self ._filename = filename
385
387
data = None
386
388
if self ._usePickleCache :
@@ -390,7 +392,7 @@ def readFileNamed(
390
392
if self ._filename .lower ().endswith ('.xls' ):
391
393
self .readExcel (worksheet , row , column )
392
394
else :
393
- with open (self ._filename ) as f :
395
+ with open (self ._filename , encoding = encoding ) as f :
394
396
self .readFile (f , delimiter , allowComments , stripWhite )
395
397
if self ._usePickleCache :
396
398
writePickleCache (self , filename , source = 'MiscUtils.DataTable' )
@@ -776,7 +778,7 @@ def __contains__(self, key):
776
778
return key in self ._nameToIndexMap
777
779
778
780
def __repr__ (self ):
779
- return '%s' % self ._values
781
+ return repr ( self ._values )
780
782
781
783
def __iter__ (self ):
782
784
for value in self ._values :
0 commit comments