-
Notifications
You must be signed in to change notification settings - Fork 51
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
Example code issue #52
Comments
@tedx your version of the example code seems to be a variation of that under the "Intercepting events" section of the documentation, but I don't think there was any problem with the original. Can you clarify what was the issue? Your version also unnecessarily opens and reads a file, so I don't understand why it's there. Other code examples in the documentation are "incomplete" in the sense they assume certain functions exist, but the examples are only for demonstration purposes and are not meant to be fully runnable code. |
The original code cut and pasted from https://github.com/ICRAR/ijson has a syntax error in that there is no colon at the end of: |
This was reported in #52. Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
@tedx that was pretty clear now, thanks :), I just pushed a fix for that. |
There are several syntax error in some of the example code. Here's a version that works:
import io
import ijson
Open a file
fo = open("foo.txt", "rb")
print ("Name of the file: ", fo.name)
line = fo.read(10)
Close opened file
fo.close()
parse_events = ijson.parse(io.BytesIO(b'["skip", {"a": 1}, {"b": 2}, {"c": 3}]'))
while True:
prefix, event, value = next(parse_events)
if value == "skip":
break
for obj in ijson.items(parse_events, 'item'):
print(obj)
The text was updated successfully, but these errors were encountered: