-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: .read_pickle(...) from zip containing hidden OS X/macOS metadata files/folders #37101
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 3 commits
df21418
7096a0e
73ac7ca
51dc013
de63161
e0a723d
2f21878
227b471
df8683c
cf34ce0
c1c0d24
6e7e300
507fd7f
59a67d7
85a5cff
9aa5924
bd9e06a
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 |
---|---|---|
|
@@ -376,6 +376,40 @@ def test_read_infer(self, ext, get_random_path): | |
|
||
tm.assert_frame_equal(df, df2) | ||
|
||
@pytest.mark.parametrize("cruft", ["__MACOSX/", ".DS_STORE"]) | ||
def test_load_zip_with_hidden_folders(self, cruft, get_random_path): | ||
"""Test loading .zip files that have extraneous metadata in hidden folders. """ | ||
ml-evs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
base = get_random_path | ||
path1 = base + ".raw" | ||
path2 = base + ".zip" | ||
dummy = base + ".dummy" | ||
ml-evs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
compression = "zip" | ||
|
||
with tm.ensure_clean(path1) as p1, tm.ensure_clean( | ||
path2 | ||
) as p2, tm.ensure_clean(dummy) as d: | ||
ml-evs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
df = tm.makeDataFrame() | ||
|
||
# write to uncompressed file | ||
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 can remove all of these comments 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. Really? I'm just following the style of other tests in this file. I've made the comments more succinct but wouldn't want to remove them altogether as this is a bit of a weird edge-case to test. |
||
df.to_pickle(p1, compression=None) | ||
|
||
# compress dataframe normally | ||
self.compress_file(p1, p2, compression=compression) | ||
|
||
# add dummy file `{cruft}{dummy}` to the archive | ||
with zipfile.ZipFile(p2, "a", compression=zipfile.ZIP_DEFLATED) as f: | ||
f.write(d, f"{cruft}{dummy}") | ||
|
||
# check the file was definitely added to the archive | ||
with zipfile.ZipFile(p2, "r") as f: | ||
assert f"{cruft}{dummy}" in f.namelist() | ||
|
||
# compressed file by inferred compression method, | ||
# dummy file should have been ignored | ||
df2 = pd.read_pickle(p2) | ||
|
||
tm.assert_frame_equal(df, df2) | ||
|
||
|
||
# --------------------- | ||
# test pickle compression | ||
|
Uh oh!
There was an error while loading. Please reload this page.