Import CSV and isolate single data point


I’m fairly new to coding in general and just started learning Opto22 last week, so most of these forum topics have gone way over my head which is why I’m posting this question, hoping for some help and simple explanations for someone with very little background.

I need to know how to take a running Excel file, make a copy of that csv file, import it into Opto, take the last value for a specific column and then make a loop so it does this every 30 min.
I know this should be possible, I just have no idea what I am doing and I don’t have anyone around me who knows anything about this program.

Thank you for any help, it is most appreciated!

Hi, welcome to the forums!

Can you make the Excel file a Google Sheet?
If so, it can be easily automated like you want via Node-RED.

The Excel file data is coming from a power supply that the PAC-R1 is communicating with and I don’t think I can change where that information is going to as far as Excel or Google Sheets.

Oh, SNAP-R1… Opps, my bad, I should have asked that up front… ie, what controller/hardware are you using…

Ok, since its an R1, I think the way I would go about it is to run Node-RED on a Windows PC.
Use a Windows bat file to pull the Excel and convert to CSV every 30 minutes.
Use Node-RED to read that CSV in and get the single column of data you want.
Then use Node-RED to do a REST call on the R1 and send it the data.

Another option would be to run SoftPAC on a Windows PC and it could pull the CSV and talk to the R1 as remote IO.

The bat file to convert the Excel to CSV will be on you, that’s outside of the Opto sandbox. (There might be others on the forums that have done this - if so, sound off please).

Do you have any other programming experience? PAC Control sounds new to you, but I am just trying to get a feel for what option might be the best, Node-RED or PAC Control… either will a little learning curve.

I have a little Python and R experience but mostly just writing functions, using solver, things like that. Mostly math based. I know the very very basic functions and idea of PAC Control from a learning suite that a professor lent to me and that’s all the experience I have with PAC Control, so I’m a very much out of my depth. My goal is just to keep this as simple as possible.
To me it sounds like using PAC Control should be simple if I can make a copy of the csv, pull the csv data into a table, get the value I need, delete the copy and repeat. I just don’t know how to do any of that…

Is getting the value from this excel file the only way to get data from the power supply? What value are you trying to get - maybe there is another way to retrieve it.

Is the file really excel, or is it CSV?

Where is it stored/how are you currently getting the data?

I’m sure there are other ways, but the project is time sensitive, so it’s more about using the resources we have quick access to at the moment. I think it is actually a CSV, which sounds like that makes it a little easier I guess.

We haven’t run any experiments with this process yet, so I can’t say with 100% certainty, but as far as I can understand the power supply sends the data to this computer in a CSV and updates it every couple of seconds. I can’t say what that looks like exactly because as I am working on this task others are working on the power supply which apparently faces it’s own problems.

What I know I need is some simple general solution to the problem of reading the CSV, taking the latest voltage reading and comparing that to a desired value and then looping this process until the desired value is reached. Due to my inexperience in basically every conceivable way in regards to this project, this is proving challenging.

Given your time constrained challenge, I would look at running Node-RED on that PC.
It takes about 2 minutes to install on Windows: Running Node-RED locally : Node-RED

Once installed, using any PC browser on the same network, I would set up my flow something like this:
Inject node set to 30 minutes, file in node to read the CSV, CSV node to get the column you want, PAC Write node to send the value to the R1 controller.

Terry has a video on CSV files here:

Here is his video on sending values to a PAC Controller:

His whole play list is here: