Share data with Excel on Windows in real time. What solution?

I have a need to share a handful of variables (four) from an Applescript(objc) project with an Excel workbook on a Windows 7 machine in real time. In real time means that Excel needs to check changes in the variables each second and the Applescript is posting changes immediately, roughly once each ten seconds.

I had hoped that I could simply use a .csv file on my Synology NAS but eventually the Applescript and the Excel workbook will try to access the file at the same time. I then tried to use a ram disk on the mac (hoping the speed of a ram disk would minimize the collision between the mac writing and the windows machine reading the file) but it didn´t help much.

I tried to throw a try block into the Applescript (the data is time sensitive but I COULD live with a one second delay). But it looks like if the Applescript has seen the file as blocked it can´t access the file again.

Bummer. But using a shared .csv file was kind of a hack anyway.

The next solutions to set up a MySQL server on the NAS and have the Applescript write and Excel read from it. But it seems like total overkill just to share a few data points and it looks like a pain in the … to implement and the Applescript side.

Any suggestion? Either on

  1. how to make the .csv route more robust.
  2. Another simple solution that isn´t vulnerable to simultaneous access.
  3. How to use MySQL (or rather the-should-be-indentical-MariaDB-on-synology) via Applescript

If one side only has read access, you shouldn’t have a problem. Assuming all the file system arrangements are aligned.

One very simple scheme, is to create a “signal file” with a name like currently_writing, that the reading side checks for, so that it knows when the writer have removed this file, because it has finished writing, then it is time to reread the contents.

When the reader starts up, it should read the contents, if there isn’t any current_writing file there, to be sure it has the right contents for starters.

That is basically all there is to it, apart from how the writing file, should reestablish the “protocol” under startup, and to resolve after a possible crash (Or user manages to quit in the middle of a write, so the currently_writing file, that is left over must be deleted.

This simple scheme assumes just one writer, and assumes very little data. The idea is, is that if the reader starts to read, just before the Writer creates the “currently writing” file, the reader should manage to finish reading before the writer starts to write. Maybe it is best for the writer to delay for a second or so, to be totally sure that the reader is finished, before the writer starts to write.

Thanks. While I didn´t use your solution I would not have thought up the “right” one. without your suggestion.

I just place the values in the file name of an empty file, remove the oldest file and have Excel list the name of the most recent file in the dedicated folder. Reading a file name doesn´t in any way conflict with writing one and as an added bonus it is speedier than reading into the file.


If that works for you, then that is all good. :slight_smile: