# Import button silently running vs opening window not working anymore

**URL:** <https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334>\
**Category:** Ignition\
**Created:** [February 11, 2021, 11:03pm UTC](https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334 "2021-02-11T23:03:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [February 11, 2021, 11:03pm UTC](https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/1 "2021-02-11T23:03:06Z")

</div>

So I have code which executes once someone fills out a text input. It automatically invisibly runs the import button for my table, pulls and writes data. This was working fine. After some adjustments when I fill out the text input it now transfers me to my table window, which it didn’t do before. I will show both code below.

WORKING CODE:  
BUTTON

```auto
import csv

#Monday Import
file = open("\\\\LOCALv\\datasource$\\LOCALTION\\Monday_WFData.csv")
csvData = csv.reader(file)

header = csvData.next()
pyData = []
for row in csvData:
	pyData.append(row)
	finalData = system.dataset.toDataSet(header,pyData)
	event.source.parent.getComponent('Monday Table').data = finalData
	

```

INPUT

```auto
value = event.source.parent.getComponent('WF Input').text
system.tag.writeToTag('System1/Efficiency/Line_6/WF_Num', value)

system.nav.openWindow("Main Windows/Table Import")
window = system.gui.getWindow("Main Windows/Table Import")
data = window.rootContainer.getComponent("Monday Table").data
system.nav.closeWindow("Main Windows/Table Import")

WF = value
	
for row in range(data.rowCount):
	index_row = data.getValueAt(row, 0)
	if index_row == WF:
		prod_nam = data.getValueAt(row, 1)
		bot_size = data.getValueAt(row, 2)
		allergen = data.getValueAt(row, 7)
		system.tag.writeToTag('System1/Efficiency/Line_6/Product_Name', prod_nam)
		system.tag.writeToTag('System1/Efficiency/Line_6/Bottle Size', bot_size)
		system.tag.writeToTag('System1/Efficiency/Line_6/ALLERGEN', allergen)
			

```

NON WORKING CODE  
BUTTON

```auto
import csv
	
#Item Master Import
file = open("\\\\LOCALv\\datasource$\\LOCALData\\Item_Master.csv")
csvData = csv.reader(file)

header = csvData.next()
pyData = []
for row in csvData:
	pyData.append(row)
	finalData = system.dataset.toDataSet(header,pyData)
	event.source.parent.getComponent('Item Master').data = finalData

```

INPUT

```auto
value = event.source.parent.getComponent('WF Input').text
system.tag.writeToTag('System1/Efficiency/Line_6/WF_Num', value)

system.nav.openWindow("Main Windows/Table Import")
window = system.gui.getWindow("Main Windows/Table Import")
data = window.rootContainer.getComponent("andrews table").data
system.nav.closeWindow("Main Windows/Table Import")

WF = value
	
for row in range(data.rowCount):
	index_row = data.getValueAt(row, 0)
	if index_row == WF:
		prod_nam = data.getValueAt(row, 1)
		bot_size = data.getValueAt(row, 2)
		allergen = data.getValueAt(row, 4)
		system.tag.writeToTag('System1/Efficiency/Line_6/Product_Name', prod_nam)
		system.tag.writeToTag('System1/Efficiency/Line_6/Bottle Size', bot_size)
		system.tag.writeToTag('System1/Efficiency/Line_6/ALLERGEN', allergen)
			

```

Thank you in advance for helping

---

<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:** [February 11, 2021, 11:09pm UTC](https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/2 "2021-02-11T23:09:04Z")

</div>

Which events?

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [February 11, 2021, 11:10pm UTC](https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/3 "2021-02-11T23:10:34Z")

</div>

Typing into an input in another window. this works without you seeing anything happen in the original project. After those code changes it now pops up the other windows.

---

<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:** [February 11, 2021, 11:12pm UTC](https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/4 "2021-02-11T23:12:11Z")

</div>

No, I mean: where in the component did you put those code blocks?

---

<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:** [February 11, 2021, 11:17pm UTC](https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/5 "2021-02-11T23:17:24Z")

</div>

Meanwhile, some notes:

Your indentation suggests that you only get one row out of your CSVs (the last row), since the output code is inside the loop. Is that what you intend?

You are closing the `Table Import` window right after extracting data from it. Is that what you intend?

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [February 11, 2021, 11:25pm UTC](https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/6 "2021-02-11T23:25:14Z")

</div>

The code is in the script editor for the button and input.

it should pull all the rows. And it does because I can reference lots of rows. The top code works seamlessly in one project. But in the duplicated project with code changes it does not.

What I want/how it works, is the operator types in xx123321, then switch to next input box. at that point the table is automatically imported. writes 3 values from the table to tags. And those tags are used to display the text information

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [February 11, 2021, 11:26pm UTC](https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/7 "2021-02-11T23:26:22Z")

</div>

i.e. if xx12321 = xx12321 pull the row that starts with xx12321 and write value1 to tag1 etc…

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [February 11, 2021, 11:49pm UTC](https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/8 "2021-02-11T23:49:22Z")

</div>

ah typo on my part got it working

---

<div class="post-metadata">

**Author:** ![chasondeshotel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chasondeshotel/32/20032_2.png) [@chasondeshotel](https://forum.inductiveautomation.com/u/chasondeshotel)\
**Post date:** [February 12, 2021, 12:53am UTC](https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/9 "2021-02-12T00:53:21Z")

</div>

> Your indentation suggests that you only get one row out of your CSVs (the last row), since the output code is inside the loop. Is that what you intend?

Look closely, `pyData` is defined outside of that scope. But you're onto something.. we _do_ have a new (aptly named) `finalData` dataset being created for every row and `Item Master` is being updated with every row. Probably not intended behavior

I imagine @andrews is wanting

```auto
pyData = []
for row in csvData:
	pyData.append(row)
finalData = system.dataset.toDataSet(header,pyData)
event.source.parent.getComponent('Item Master').data = finalData

```

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [February 12, 2021, 5:24pm UTC](https://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/10 "2021-02-12T17:24:48Z")

</div>

Just a typo in the code you can see above.
