@@ -88,6 +88,7 @@ def setUp(self):
88
88
self .xls1 = os .path .join (self .dirpath , 'test.xls' )
89
89
self .xlsx1 = os .path .join (self .dirpath , 'test.xlsx' )
90
90
self .multisheet = os .path .join (self .dirpath , 'test_multisheet.xlsx' )
91
+ self .multi_ods = os .path .join (self .dirpath , 'test_multisheet.ods' )
91
92
self .ods1 = os .path .join (self .dirpath , 'test.ods' )
92
93
self .frame = _frame .copy ()
93
94
self .frame2 = _frame2 .copy ()
@@ -460,59 +461,63 @@ def test_reader_converters(self):
460
461
for path in (xls_path , xlsx_path , ods_path ):
461
462
actual = read_excel (path , 'Sheet1' , converters = converters )
462
463
tm .assert_frame_equal (actual , expected )
463
-
464
+
464
465
def test_reading_all_sheets (self ):
465
466
# Test reading all sheetnames by setting sheetname to None,
466
467
# Ensure a dict is returned.
467
468
# See PR #9450
468
-
469
+
469
470
_skip_if_no_xlrd ()
470
-
471
- dfs = read_excel (self .multisheet ,sheetname = None )
472
- expected_keys = ['Alpha' ,'Beta' ,'Charlie' ]
473
- tm .assert_contains_all (expected_keys ,dfs .keys ())
471
+ _skip_if_no_ezodf ()
472
+
473
+ for multi in [self .multisheet , self .multi_ods ]:
474
+ dfs = read_excel (multi , sheetname = None )
475
+ expected_keys = ['Alpha' , 'Beta' , 'Charlie' ]
476
+ tm .assert_contains_all (expected_keys , dfs .keys ())
474
477
475
478
def test_reading_multiple_specific_sheets (self ):
476
- # Test reading specific sheetnames by specifying a mixed list
479
+ # Test reading specific sheetnames by specifying a mixed list
477
480
# of integers and strings, and confirm that duplicated sheet
478
481
# references (positions/names) are removed properly.
479
-
482
+
480
483
# Ensure a dict is returned
481
484
# See PR #9450
482
485
_skip_if_no_xlrd ()
483
-
484
- #Explicitly request duplicates. Only the set should be returned.
485
- expected_keys = [2 ,'Charlie' ,'Charlie' ]
486
- dfs = read_excel (self .multisheet ,sheetname = expected_keys )
487
- expected_keys = list (set (expected_keys ))
488
- tm .assert_contains_all (expected_keys ,dfs .keys ())
489
- assert len (expected_keys ) == len (dfs .keys ())
486
+ _skip_if_no_ezodf ()
487
+
488
+ # Explicitly request duplicates. Only the set should be returned.
489
+ for multi in [self .multisheet , self .multi_ods ]:
490
+ expected_keys = [2 , 'Charlie' , 'Charlie' ]
491
+ dfs = read_excel (multi , sheetname = expected_keys )
492
+ expected_keys = list (set (expected_keys ))
493
+ tm .assert_contains_all (expected_keys , dfs .keys ())
494
+ assert len (expected_keys ) == len (dfs .keys ())
490
495
491
496
def test_creating_and_reading_multiple_sheets (self ):
492
497
# Test reading multiple sheets, from a runtime created excel file
493
498
# with multiple sheets.
494
- # See PR #9450
495
-
499
+ # See PR #9450
500
+
496
501
_skip_if_no_xlrd ()
497
502
_skip_if_no_xlwt ()
498
-
503
+
499
504
def tdf (sheetname ):
500
505
d , i = [11 ,22 ,33 ], [1 ,2 ,3 ]
501
506
return DataFrame (d ,i ,columns = [sheetname ])
502
-
507
+
503
508
sheets = ['AAA' ,'BBB' ,'CCC' ]
504
-
509
+
505
510
dfs = [tdf (s ) for s in sheets ]
506
511
dfs = dict (zip (sheets ,dfs ))
507
-
512
+
508
513
with ensure_clean ('.xlsx' ) as pth :
509
514
with ExcelWriter (pth ) as ew :
510
515
for sheetname , df in dfs .iteritems ():
511
516
df .to_excel (ew ,sheetname )
512
517
dfs_returned = pd .read_excel (pth ,sheetname = sheets )
513
518
for s in sheets :
514
519
tm .assert_frame_equal (dfs [s ],dfs_returned [s ])
515
-
520
+
516
521
def test_reader_seconds (self ):
517
522
# Test reading times with and without milliseconds. GH5945.
518
523
_skip_if_no_xlrd ()
0 commit comments