Git Product home page Git Product logo

Comments (7)

rtobar avatar rtobar commented on July 21, 2024

@faker09 you'll need to provide more details, otherwise it's nearly impossible to give any advice. Also look if any ijson questions in StackOverflow cover what you need.

from ijson.

faker09 avatar faker09 commented on July 21, 2024

because my json file is too large(8GB), i wanna use ijson.items to read this file.

below example

{"datum":{"com.bbn.tc.schema.avro.cdm20.Event":{"uuid":"A.-\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","sequence":null,"type":"EVENT_CREATE_OBJECT","threadId":{"int":3056},"subject":{"com.bbn.tc.schema.avro.cdm20.UUID":"u*N\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"},"predicateObject":{"com.bbn.tc.schema.avro.cdm20.UUID":">\"-\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"},"predicateObjectPath":{"string":"C:\\Users\\admin\\Documents\\Documents"},"predicateObject2":null,"predicateObject2Path":null,"timestampNanos":1557272968456297200,"names":null,"parameters":null,"location":null,"size":null,"programPoint":null,"properties":{"map":{"HasMacro":"4"}}}},"CDMVersion":"20","type":"RECORD_HOST","hostId":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","sessionNumber":0,"source":"SOURCE_WINDOWS_MARPLE"}

{"datum":{"com.bbn.tc.schema.avro.cdm20.Event":{"uuid":"B.-\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","sequence":null,"type":"EVENT_OTHER","threadId":{"int":3056},"subject":{"com.bbn.tc.schema.avro.cdm20.UUID":"u*N\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"},"predicateObject":{"com.bbn.tc.schema.avro.cdm20.UUID":">\"-\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"},"predicateObjectPath":{"string":"C:\\Users\\admin\\Documents\\Documents"},"predicateObject2":null,"predicateObject2Path":null,"timestampNanos":1557272968456415900,"names":{"array":["FileIoClose"]},"parameters":null,"location":null,"size":null,"programPoint":null,"properties":null}},"CDMVersion":"20","type":"RECORD_HOST","hostId":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","sessionNumber":0,"source":"SOURCE_WINDOWS_MARPLE"}

{"datum":{"com.bbn.tc.schema.avro.cdm20.Event":{"uuid":"C.-\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","sequence":null,"type":"EVENT_CREATE_OBJECT","threadId":{"int":3056},"subject":{"com.bbn.tc.schema.avro.cdm20.UUID":"u*N\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"},"predicateObject":{"com.bbn.tc.schema.avro.cdm20.UUID":">\"-\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"},"predicateObjectPath":{"string":"C:\\Users\\admin\\Documents\\Documents"},"predicateObject2":null,"predicateObject2Path":null,"timestampNanos":1557272968456469400,"names":null,"parameters":null,"location":null,"size":null,"programPoint":null,"properties":{"map":{"HasMacro":"4"}}}},"CDMVersion":"20","type":"RECORD_HOST","hostId":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","sessionNumber":0,"source":"SOURCE_WINDOWS_MARPLE"}

from ijson.

faker09 avatar faker09 commented on July 21, 2024

i means that if i use

data_json=ijson.items(filename, 'item')
for i in data_json:
      print(i)

it don't output anything

from ijson.

rtobar avatar rtobar commented on July 21, 2024

@faker09 the problem is you are passing ijson the filename instead of a file object. You need to open your file yourself, then give the resulting file object to ijson.

from ijson.

faker09 avatar faker09 commented on July 21, 2024

@ faker09问题是您要通过ijson传递文件名而不是文件对象。您需要自己打开文件,然后将生成的文件对象提供给ijson。

sorry, i use a confusing parameter name. actually, i opened a file and pass a file object to ijson.items()

from ijson.

rtobar avatar rtobar commented on July 21, 2024

@faker09 can you please then provide a cleaner extract of your JSON file? In particular, how does the file start? I get the impression you have a file with multiple top-level JSON objects instead of a single one, in which case you'll need to use an empty prefix and multiple_values=True when invoking ijson.items. But again, if you provide a cleaner extract of the JSON file (make sure it formats correctly when putting it into the comments here), the code you are using, and any error you might be receiving, it would be better.

from ijson.

rtobar avatar rtobar commented on July 21, 2024

Closing for lack of clearer explanations.

from ijson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.