-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
SAS chunksize / iteration issues #14743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,4 +83,3 @@ Performance Improvements | |
|
||
Bug Fixes | ||
~~~~~~~~~ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,27 +44,46 @@ def test_from_buffer(self): | |
df0 = self.data[j] | ||
for k in self.test_ix[j]: | ||
fname = os.path.join(self.dirpath, "test%d.sas7bdat" % k) | ||
with open(fname, 'rb') as f: | ||
byts = f.read() | ||
buf = io.BytesIO(byts) | ||
df = pd.read_sas(buf, format="sas7bdat", encoding='utf-8') | ||
df = pd.read_sas(fname, encoding="utf-8") | ||
tm.assert_frame_equal(df, df0, check_exact=False) | ||
|
||
def test_from_iterator(self): | ||
for j in 0, 1: | ||
df0 = self.data[j] | ||
for k in self.test_ix[j]: | ||
fname = os.path.join(self.dirpath, "test%d.sas7bdat" % k) | ||
with open(fname, 'rb') as f: | ||
byts = f.read() | ||
buf = io.BytesIO(byts) | ||
rdr = pd.read_sas(buf, format="sas7bdat", | ||
iterator=True, encoding='utf-8') | ||
rdr = pd.read_sas(fname, iterator=True, encoding='utf-8') | ||
df = rdr.read(2) | ||
tm.assert_frame_equal(df, df0.iloc[0:2, :]) | ||
df = rdr.read(3) | ||
tm.assert_frame_equal(df, df0.iloc[2:5, :]) | ||
|
||
def test_iterator_loop(self): | ||
# github #13654 | ||
for j in 0, 1: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add the issue references here |
||
for k in self.test_ix[j]: | ||
for chunksize in 3, 5, 10, 11: | ||
fname = os.path.join(self.dirpath, "test%d.sas7bdat" % k) | ||
rdr = pd.read_sas(fname, chunksize=10, encoding='utf-8') | ||
y = 0 | ||
for x in rdr: | ||
y += x.shape[0] | ||
self.assertTrue(y == rdr.row_count) | ||
|
||
def test_iterator_read_too_much(self): | ||
# github #14734 | ||
k = self.test_ix[0][0] | ||
fname = os.path.join(self.dirpath, "test%d.sas7bdat" % k) | ||
with open(fname, 'rb') as f: | ||
byts = f.read() | ||
buf = io.BytesIO(byts) | ||
rdr = pd.read_sas(buf, format="sas7bdat", | ||
iterator=True, encoding='utf-8') | ||
d1 = rdr.read(rdr.row_count + 20) | ||
rdr = pd.read_sas(fname, iterator=True, encoding="utf-8") | ||
d2 = rdr.read(rdr.row_count + 20) | ||
tm.assert_frame_equal(d1, d2) | ||
|
||
|
||
def test_encoding_options(): | ||
dirpath = tm.get_data_path() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is more logical to keep the buffer reading here, as this test is called "test_from_buffer" is I suppose is exactly testing this (and then maybe use plain reading from file in "test_iterator_read_too_much")