Page 1 of 1

Combining Rats and Python

Posted: Tue Nov 13, 2018 5:13 am
by Finn Weiss
Hey all,
i am trying to make my data updating more automatically. Therefor i want to use python. I wanted to ask, if anybody has used python to create a ratsdata file or if anybody has even worked with python and rats togehter.
My aim is to write data into a rats datafile using python.

Best Regards

Re: Combining Rats and Python

Posted: Tue Nov 13, 2018 1:55 pm
by PeterF
Hello Finn,

I have not written data directly from Python into a RATS data file. However, I have found a way to read some data into RATS directly. From there, it would be a small step to store the data in a RAT-file.

My solution works as followed: Since version 9.1 RATS has the open to read data from a URL if the data is in one of the supported formats, for example as csv data. This feature could be applied to read data, which is not supported. All what is needed is a small web-server program replying to a request by reading the data specified in a URL string and send a reply with the data in html protocol. I implemented the web-server for the localhost in VB.Net.

In RATS you send a request for the data to your Python web-server in a URL string with the Open Data instruction. The web-server for the localhost would get the html message, read the data and sends it back in a html reply to RATS, which reads the data with the DATA instruction like it would read it from your hard-disk. Once the data provided by Python is in the RAM, you could store it in a RATS data file on your hard-disk with the usual instructions.

If you use Python only to read data from a web-site, then you could use the URL string also to read the data into RATS directly. For more information use the keyword URL in the RATS online help for more information and an example

Best regards
Peter