Code error in PsychoPy3

Hi,
I’m trying to run an script written in the older version of PsychoPy. It runs perfectly well in PsychoPy1.90.3 but gives an error in the latest version. The error is at the following section of the script:

# Define trials from csv
if expInfo['run'] == 1:
    csv_file = "trial_list/trials_run1.csv"
elif expInfo['run'] == 2:
    csv_file = "trial_list/trials_run2.csv"

trial_csv = pd.read_csv(csv_file)

The error that i get is csv_file not defined. Any ideas as to what syntax has changed between the versions.
Thanks.

Any suggestions on my query?

expInfo is text so try

if expInfo['run'] == '1':
    csv_file = "trial_list/trials_run1.csv"
elif expInfo['run'] == '2':
    csv_file = "trial_list/trials_run2.csv"

though personally I tend to have a default

if expInfo['run'] == '1':
    csv_file = "trial_list/trials_run1.csv"
else:
    csv_file = "trial_list/trials_run2.csv"

Thank you