Access data in Excel - Reuter from python

2019-01-23 10:27发布

问题:

I'm using Reuters integrated in Excel to retrieve market data. For task automation , I currently use VBA but now I want to switch to python. The package pyxll does not help much because the principle is the same as VBA (I need to be inside Excel and click on the RUN button...) So I'm considering using win32com to access to Excel from outside with COM object. However, when I do:

from win32com.client import Dispatch 
xlApp = Dispatch("Excel.Application")

This code opens a new instance of Excel that does not have Reuter add-in in there (thus I can't use the Reuter function to retrieve data). I don't know how to access to Excel-with-Reuter instance from python? I've taken a look at Com Explorer to explore the service and I didn't see any other service than Excel

回答1:

Try this -

import os
from win32com.client import GetObject

os.startfile(r'C:\path\to\ReutersExcel.exe')
xlApp = GetObject(None, 'Excel.Application')


回答2:

If you're using Excel to access Thomson Reuters Dataworks Enterprise (former Datastream), then have a look on pydatastream (https://github.com/vfilimonov/pydatastream) - it'll allow you to get the data directly to python in pandas.DataFrame format.



回答3:

If you are using Excel VBA, it is have a very high chance for an incorrect result (You also have a very hard time to write more codes to handle states that might cause the problem as well).

From my experience, we should consume the data directly from the feed and manipulate it. It is easily to maintain as well as reliable (Definitely I do this in python).

I am using PyRFA to consume the data from my P2PS and manipulate it (This API is great as it currently free of charge! it provides both consumer and provider capability). Here's more detail of this API:

http://www.devcartel.com/pyrfa

What you need to do is contacting to their support team for more details and boom coding begin!

Cheers, Michael



回答4:

you can launch the add-ins with this code: make sur before you have the automatic sign-in selected.

Import win32com.client
xl = win32com.client.DispatchEx("Excel.Application")