Mastering Development

Append function seems doesn’t works in Python

I need an array of JSON files to insert in a DB because bulk_doc (array_of_json) is more efficient and faster than Createdoc (json_doc)
I wrote this code:

    with open('C:\DATA_VOTES_CST_PTY.csv', 'r') as f:
       key = f.readline().replace('\n', '').replace('\"', '').split(',')
       while (True) :
           line = f.readline()
           if (line == '') :
           else :
               value = line.replace('\n', '').replace('\"', '').split(',')
           for i in range(len(key)):
               app.update({key[i] : value[i]})
           json_doc = json.dumps(app)
           print(json_doc) #print what I want
       print("\n", json_doc)
print("now print docs: ")
print(docs) #print nothing, neither errors

The doc contains one 1Milion of lines. I don’t know what to do about this problem, it seems like append dosen’t work.

PS: I’m using Python 3.8 on Spyder4 Anaconda

the output

Leave a Reply

Your email address will not be published. Required fields are marked *