Import button silently running vs opening window not working anymore

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

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

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

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

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

Which events?

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.

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

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?

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

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

ah typo on my part got it working

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

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

Just a typo in the code you can see above.