Skip to content

Commit

Permalink
Merge pull request #12 from perrygreenfield/fixrawread
Browse files Browse the repository at this point in the history
fixed brittle raw read of asdf file and conversion to string
  • Loading branch information
perrygreenfield authored Aug 28, 2021
2 parents c067aa9 + 26de387 commit 6e771de
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Anatomy_of_an_ASDF_file.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@
"outputs": [],
"source": [
"# Open as an ordinary file first\n",
"with open('tut_with_data.asdf','rb') as taf2: print(taf2.read())"
"with open('tut_with_data.asdf','rb') as taf2:\n",
" print(taf2.read())"
]
},
{
Expand All @@ -154,7 +155,10 @@
"outputs": [],
"source": [
"# Print as string, but requires conversion of text part\n",
"with open('tut_with_data.asdf','rb') as taf2: print(taf2.read()[:852].decode(\"utf-8\"))"
"with open('tut_with_data.asdf','rb') as taf2:\n",
" fbytes = taf2.read()\n",
" end = fbytes.find(b'...')\n",
" print(fbytes[: end + 3].decode(\"utf-8\"))"
]
},
{
Expand Down Expand Up @@ -474,6 +478,13 @@
"Delete data2 and save the under a different name. Open the saved file and verify\n",
"it contains the new items."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 6e771de

Please sign in to comment.