Importing saved CSV recipe data back to my dataset

So I am tasked with storing recipes (datasets) generated within my application and then saved to the C drive via a command. I have this working.

The next step I need to figure out is generating a pulldown list of the saved CSV files (these recipes will be saved and stored right away and then recalled whenever). I am not sure where to start on this one.

Lastly, with the pulldown list generated, the user would be able to select a csv file from the pulldown list and select my “load” button which would repopulate the dataset.

Any help on this would be greatly appreciated.

Before you go far down this path, is there a reason you aren’t using a database? This is precisely the kind of task they are made to handle. And a task that Ignition’s database connections handle very well, indeed.

I would gladly take the easier route

I recommend two tables in your database:

  1. Recipe data. Set up the same columns as you would have in your CSV, plus two more: a recipe_id integer, and a seq integer (short for sequence).

  2. Recipe meta-data. Have a recipe_id primary key, plus any other information about the recipe, like its name, description, maybe a product code, etc.

Show the second when selecting a recipe. Show and use the first when applying or editing a recipe.

What SQL database have you installed? MS SQL? MySQL?
What database editor do you have?

Write some script to navigate in OS paths and load data from selected. Many libraries out there like os that uses python. Or if you're a java fan, maybe io.file.

Anyways. I would take the DB advice.

I am using MySQL

OK. Then install something like MySQL Workbench or one of several other options.

  • Create a schema (a database).
  • Create a table in the schema and add in a column for each line of your recipe. Think this one through. You may need some additional fields such as “recipe name”, “approval status” (to restrict production personnel to using approved recipes only) and “approval date”, etc.
  • Enter your recipe data. One recipe per row of the database.

You can now retrieve the recipe with a named database query, populate a drop-down of recipe names and, on selection of a new recipe, write the recipe parameters to the PLC tags.

When you get more proficient you can create a recipe editor function in your application.

That's probably too simplistic, if the current idea uses a CSV file per recipe. Rows in the CSV would correspond to steps in the recipe. That's why I recommended two tables.

1 Like

yes, a recipe will have up to 15 steps (at this point in time, might be more later). Each recipe has 21 setpoints (so 21x15), indicator number is the “step number”. The saved total recipe count will be adjusted via creating a new recipe with a new name and the save button pressed. I am new to the query builder and mySQL so any advice is appreciated.

Apparently you were correct - although there was nothing in the question to indicate a sequence was required.
Most of my work is with medical product high-volume machine operating parameters so each recipe is one line of a table and each column gives the time, temperature, pressure, etc. A simple flat table is sufficient and, quite often, a CSV file is employed. The machines are not using our Ignition installation (yet!).