# Importing saved CSV recipe data back to my dataset

**URL:** <https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536>\
**Category:** Ignition\
**Tags:** python\
**Created:** [April 17, 2022, 11:39pm UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536 "2022-04-17T23:39:09Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Holly](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Andrew\_Holly](https://forum.inductiveautomation.com/u/Andrew_Holly)\
**Post date:** [April 17, 2022, 11:39pm UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536/1 "2022-04-17T23:39:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 17, 2022, 11:42pm UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536/2 "2022-04-17T23:42:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Andrew\_Holly](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Andrew\_Holly](https://forum.inductiveautomation.com/u/Andrew_Holly)\
**Post date:** [April 17, 2022, 11:51pm UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536/3 "2022-04-17T23:51:01Z")

</div>

I would gladly take the easier route

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 18, 2022, 12:01am UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536/4 "2022-04-18T00:01:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 18, 2022, 12:01am UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536/5 "2022-04-18T00:01:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [April 18, 2022, 1:19am UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536/6 "2022-04-18T01:19:12Z")

</div>

> [@Andrew\_Holly](#):
>
> I am not sure where to start on this one

Write some script to navigate in OS paths and load data from selected. Many libraries out there like [os](https://docs.python.org/2.7/library/os.html) that uses python. Or if you're a java fan, maybe [io.file](https://docs.oracle.com/javase/7/docs/api/java/io/File.html).

Anyways. I would take the DB advice.

---

<div class="post-metadata">

**Author:** ![Andrew\_Holly](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Andrew\_Holly](https://forum.inductiveautomation.com/u/Andrew_Holly)\
**Post date:** [April 18, 2022, 12:54pm UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536/7 "2022-04-18T12:54:08Z")

</div>

I am using MySQL

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 18, 2022, 1:01pm UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536/8 "2022-04-18T13:01:41Z")

</div>

OK. Then install something like [MySQL Workbench](https://www.mysql.com/products/workbench/) or [one of several other options](https://tableplus.com/blog/2018/10/sqlyog-vs-navicat-vs-tableplus.html).

- 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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 18, 2022, 1:36pm UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536/9 "2022-04-18T13:36:35Z")

</div>

> [@Transistor](#):
>
> Create a table in the schema and add in a column for each line of your recipe

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.

---

<div class="post-metadata">

**Author:** ![Andrew\_Holly](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Andrew\_Holly](https://forum.inductiveautomation.com/u/Andrew_Holly)\
**Post date:** [April 18, 2022, 1:53pm UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536/10 "2022-04-18T13:53:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 18, 2022, 2:07pm UTC](https://forum.inductiveautomation.com/t/importing-saved-csv-recipe-data-back-to-my-dataset/58536/11 "2022-04-18T14:07:26Z")

</div>

> [@pturmel](#):
>
> That’s probably too simplistic ...

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!).
