TRTH: Python Extract market depth data

Hi,

I'm in trouble to extract data from http response object.

I can't figure out how to extract data using job ID and $value endpoint. Use case reference says users can download the report by folowing final step, but can't find any gzip file in my directory.

How can I retrieve or find data from report_gzip or anyother types of objjects?

Thanks,

report_gzip= requests.get( "https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/RawExtractionResults('0x05c5d18a57bb2f96')/$value",
headers = header2, stream=True)

Best Answer

  • @YK_deprecated_1

    The raw extraction result will be streamed in gzip format, and then stored in the Response object. You can use this method of the Python Requests module to save raw gzip streamed response to file.

    Below is the sample code. You can also see this question.

    filename = "result.csv.gz"

    with open(filename,'wb') as f:
    for data in report_gzip.raw.stream(decode_content=False):
    f.write(data)

Answers