@@ -44,22 +44,15 @@ def test_from_buffer(self):
44
44
df0 = self .data [j ]
45
45
for k in self .test_ix [j ]:
46
46
fname = os .path .join (self .dirpath , "test%d.sas7bdat" % k )
47
- with open (fname , 'rb' ) as f :
48
- byts = f .read ()
49
- buf = io .BytesIO (byts )
50
- df = pd .read_sas (buf , format = "sas7bdat" , encoding = 'utf-8' )
47
+ df = pd .read_sas (fname , encoding = "utf-8" )
51
48
tm .assert_frame_equal (df , df0 , check_exact = False )
52
49
53
50
def test_from_iterator (self ):
54
51
for j in 0 , 1 :
55
52
df0 = self .data [j ]
56
53
for k in self .test_ix [j ]:
57
54
fname = os .path .join (self .dirpath , "test%d.sas7bdat" % k )
58
- with open (fname , 'rb' ) as f :
59
- byts = f .read ()
60
- buf = io .BytesIO (byts )
61
- rdr = pd .read_sas (buf , format = "sas7bdat" ,
62
- iterator = True , encoding = 'utf-8' )
55
+ rdr = pd .read_sas (fname , iterator = True , encoding = 'utf-8' )
63
56
df = rdr .read (2 )
64
57
tm .assert_frame_equal (df , df0 .iloc [0 :2 , :])
65
58
df = rdr .read (3 )
@@ -71,11 +64,7 @@ def test_iterator_loop(self):
71
64
for k in self .test_ix [j ]:
72
65
for chunksize in 3 , 5 , 10 , 11 :
73
66
fname = os .path .join (self .dirpath , "test%d.sas7bdat" % k )
74
- with open (fname , 'rb' ) as f :
75
- byts = f .read ()
76
- buf = io .BytesIO (byts )
77
- rdr = pd .read_sas (buf , format = "sas7bdat" ,
78
- chunksize = chunksize , encoding = 'utf-8' )
67
+ rdr = pd .read_sas (fname , chunksize = 10 , encoding = 'utf-8' )
79
68
y = 0
80
69
for x in rdr :
81
70
y += x .shape [0 ]
@@ -90,7 +79,10 @@ def test_iterator_read_too_much(self):
90
79
buf = io .BytesIO (byts )
91
80
rdr = pd .read_sas (buf , format = "sas7bdat" ,
92
81
iterator = True , encoding = 'utf-8' )
93
- rdr .read (rdr .row_count + 20 )
82
+ d1 = rdr .read (rdr .row_count + 20 )
83
+ rdr = pd .read_sas (fname , iterator = True , encoding = "utf-8" )
84
+ d2 = rdr .read (rdr .row_count + 20 )
85
+ tm .assert_frame_equal (d1 , d2 )
94
86
95
87
96
88
def test_encoding_options ():
0 commit comments