0

my code looks like this

username = 'user'
password = 'user'
url = 'http://di4301sw:8081/solr/metadone/select?fl=file.contenu&q=patient.ipp:3456&rows=14'
r = requests.get(url, auth=(username, password)) 
data = r.json()
with open('data.json', 'w') as f:
    json.dump(data, f)

and my result looks like this

{"responseHeader": {"status": 0, "QTime": 0, "params": {"q": "patient.ipp:3456", "fl": "file.contenu", "rows": "14"}}, "response": {"numFound": 14, "start": 0, "docs": [{"file.contenu": "Biochimie d'urgence Dr F. Beyerle, Dr L. Chardon, A. Varennes Tel Secr\u00e9tariat

i want the result to start from "file.contenu" i.e. i dont want the header Thanks in anticipation

khelwood
  • 55,782
  • 14
  • 81
  • 108

2 Answers2

1

you should parse the response in order to get the desired result:

data_to_dump=data['response']['docs'][0]

hope this helps

Tarique
  • 1,273
  • 9
  • 15
1

There is a URL parameter for this, called omitHeader.

From the documentation:

If set to true, this parameter excludes the header from the returned results.

stalskal
  • 1,181
  • 1
  • 8
  • 16
  • Unfortunately the JSON object returned will sill have `{ "response":{"numFound":1,"start":0,"numFoundExact":true,"docs":[` to start with this parameter. Gets the OP closer but not exactly what they want. – nosvalds Feb 24 '22 at 11:24