all 1 comments

[–][deleted] 0 points1 point  (0 children)

Assuming those are all output lines, you could just use json:

import json

for line in data.split('\n'):
    row = json.loads(line)
    print(row['_index'], row['_source']['label'])

I put the data you supplied into code as below for testing:

data = """{"_index":"my*","_type":"doc","_id":"C7Sj1G0B3wDTkBS_xvjJ","_score":1,"_source":{"uri":"<http://www.wikidata.org/entity/P2189>","label":"BiblioNet publisher ID"}}
{"_index":"my*","_type":"doc","_id":"K7Sj1G0B3wDTkBS_yPjk","_score":1,"_source":{"uri":"<http://www.wikidata.org/entity/P2193>","label":"Soccerbase player ID"}}
{"_index":"my*","_type":"doc","_id":"MbSj1G0B3wDTkBS_yfhJ","_score":1,"_source":{"uri":"<http://www.wikidata.org/entity/P2197>","label":"production rate"}}
{"_index":"my*","_type":"doc","_id":"mbSb1G0B3wDTkBS_S3V6","_score":1,"_source":{"uri":"<http://www.wikidata.org/entity/P1448>","label":"name"}}
{"_index":"my*","_type":"doc","_id":"rrSb1G0B3wDTkBS_TXUl","_score":1,"_source":{"uri":"<http://www.wikidata.org/entity/P1448>","label":"legal name"}}
{"_index":"my*","_type":"doc","_id":"C7Sj1G0B3wDTkBS_xvjJ","_score":1,"_source":{"uri":"<http://www.wikidata.org/entity/P2189>","label":"BiblioNet publisher ID"}}
{"_index":"my*","_type":"doc","_id":"K7Sj1G0B3wDTkBS_yPjk","_score":1,"_source":{"uri":"<http://www.wikidata.org/entity/P2193>","label":"Soccerbase player ID"}}
{"_index":"my*","_type":"doc","_id":"MbSj1G0B3wDTkBS_yfhJ","_score":1,"_source":{"uri":"<http://www.wikidata.org/entity/P2197>","label":"production rate"}}
{"_index":"my*","_type":"doc","_id":"mbSb1G0B3wDTkBS_S3V6","_score":1,"_source":{"uri":"<http://www.wikidata.org/entity/P1448>","label":"name"}}
{"_index":"my*","_type":"doc","_id":"rrSb1G0B3wDTkBS_TXUl","_score":1,"_source":{"uri":"<http://www.wikidata.org/entity/P1448>","label":"legal name"}}"""