Skip to content Skip to sidebar Skip to footer

Recover All Line From An Attribute In A Database In Json

To simplify my problem, I have a base in json, and I recover all of my lines of json to put informations in a base. It seems easy for moments, but problem is that my json is not

Solution 1:

For exemple, I wanted say that : I have a file , openlibraryjson.json :

with these lines :

{"name": "Ismail Ibrahim Dr.", "title": "Dr.", "personal_name": "Ismail Ibrahim", "last_modified": {"type": "/type/datetime", "value": "2008-04-01T03:28:50.625462"}, "key": "/authors/OL100304A", "type": {"key": "/type/author"}, "revision": 1} {"bio": {"type": "/type/text", "value": "> "Eversley, William Pinder, B.C.L. Queen's Coll., Oxon, M.A., a member of the South-eastern circuit, reporter for Law Times in Queen's Bench division, a student of the Inner Temple 14 April, 1874 (then aged 23), called to the bar 25 April, 1877 (eldest son of William Eversley, Esq., of London); born u2060, 1851. rn> rn> 7, King's Bench Walk, Temple, E.C." rn> ...[in Foster's Men at the Bar][1]rnrnrn rnrn[1]: https://en.wikisource.org/wiki/Men-at-the-Bar/Eversley,_William_Pinder "Men at the Bar""}, "name": "William Pinder Eversley", "created": {"type": "/type/datetime", "value": "2008-04-01T03:28:50.625462"}, "death_date": "1918", "photos": [6897255, 6897254], "last_modified": {"type": "/type/datetime", "value": "2018-07-31T15:39:07.982159"}, "latest_revision": 6, "key": "/authors/OL1003081A", "birth_date": "1851", "personal_name": "William Pinder Eversley", "type": {"key": "/type/author"}, "revision": 6} {"name": "Valerie Meyer", "personal_name": "Valerie Meyer", "last_modified": {"type": "/type/datetime", "value": "2008-08-20T18:22:33.63997"}, "key": "/authors/OL1004062A", "type": {"key": "/type/author"}, "revision": 2} {"bio": {"type": "/type/text", "value": "[Deutsch] Deutscher Orientalist und Theologe.rn[English] German orientalist and biblical scholar."}, "name": "August Dillmann", "links": [{"url": "http://de.wikipedia.org/wiki/August_Dillmann", "type": {"key": "/type/link"}, "title": "Wikipedia (Deutsch)"}, {"url": "http://en.wikipedia.org/wiki/August_Dillmann", "type": {"key": "/type/link"}, "title": "Wikipedia (English)"}], "personal_name": "August Dillmann", "death_date": "4 July 1894.", "alternate_names": ["Christian Friedrich August Dillmann", "Ch. F. A. Dillmann", "Friedrich August Dillmann", "F. A. Dillmann", "Augustus Dillmann", "August Dillmann", "A. Dillmann"], "created": {"type": "/type/datetime", "value": "2008-04-01T03:28:50.625462"}, "photos": [6676274], "last_modified": {"type": "/type/datetime", "value": "2017-03-31T12:45:57.925108"}, "latest_revision": 8, "key": "/authors/OL1179559A", "birth_date": "25 April 1823", "revision": 8, "type": {"key": "/type/author"}, "remote_ids": {"viaf": "45046685", "wikidata": "Q75216"}} {"last_modified": {"type": "/type/datetime", "value": "2008-04-01T03:28:50.625462"}, "type": {"key": "/type/author"}, "name": "Physikertagung (1966 Munich, Germany)", "key": "/authors/OL1179696A", "revision": 1}

I would like take only line bio and treat them to put them functionnal, for it I tried to open my file, and I Treat name,personal_name ... with a loop, it works but not for bio because it's not written correctly, so I skip bio in my script for moment But now i would like to don't skip bio and work with bio in the same way that for name,personal_name ...

Like it :

with open('openlibrary(3).json') as file: for i in range(101): line = file.readline() if "bio" in line: line.replace("\'", "’") continue content_json = json.loads(line) if not "personal_name" in line: #print('NULL') ligne.append("NULL") continue try: #print(content_json['name']) ligne.append(content_json['personal_name']) except IndexError: print('NULL') if not "personal_name" in line: # print('NULL') personal_nom.append("NULL") continue try: # print(content_json['name']) personal_nom.append(content_json['personal_name']) except IndexError: print('NULL')

I just put some code here to show a bit what i did for name,personal_name...

Thanks you again for listen me and aswer me !!!!

Post a Comment for "Recover All Line From An Attribute In A Database In Json"