-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: windows with TemporaryFile an read_csv #13398 #13481
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
Changes from 6 commits
d8decae
5af8465
119fb65
98e476e
fd20aaf
d8ceb57
1c33fb5
aa3f0aa
5871625
0d54151
8b52631
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,3 +171,25 @@ def test_read_table_buglet_4x_multiindex(self): | |
columns=list('abcABC'), index=list('abc')) | ||
actual = self.read_table(StringIO(data), sep='\s+') | ||
tm.assert_frame_equal(actual, expected) | ||
|
||
def test_temporary_file(self): | ||
# GH13398 | ||
data1 = """index,A,B,C,D | ||
foo,2,3,4,5 | ||
bar,7,8,9,10 | ||
baz,12,13,14,15 | ||
qux,12,13,14,15 | ||
foo2,12,13,14,15 | ||
bar2,12,13,14,15 | ||
""" | ||
data2 = data1.replace(",", " ") | ||
|
||
from tempfile import TemporaryFile | ||
new_file = TemporaryFile("w+") | ||
new_file.write(data2) | ||
new_file.flush() | ||
new_file.seek(0) | ||
|
||
result = self.read_csv(new_file, sep=r"\s+", engine="python") | ||
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. You don't need to specify the engine here because it's already specified as Python only. General rule of thumb for these tests: you shouldn't need to explicitly specify the engine. |
||
expected = self.read_csv(StringIO(data1)) | ||
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. Better practice is to explicitly define your expected output by constructing the DataFrame itself. If you want, you can simplify your data input to make this construction easier to write out (does your data need to be that long for the error to be triggered - why not that nice simple data you used in your initial commit?) 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. I was trying to be too clever. I reused the data from test_common, should have reverted it back. |
||
tm.assert_frame_equal(result, expected) |
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.
Why do we need to do this? What's wrong with
data = "0 0"
?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.
Nothing. It's late Sunday evening with a crappy game on tv :p
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.
Join the club! 😄