← Back to team overview

sikuli-driver team mailing list archive

[Question #191201]: CSV Reading Name Error....

 

New question #191201 on Sikuli:
https://answers.launchpad.net/sikuli/+question/191201

I'm currently raging at this, it worked a little earlier but then I added a new line and now it's stopped altogether.
Can anyone point out the obv flaw?

Sikuli code:
---------------------------------------------------------------------
import csv
xReader = file("C:\\Users\\davidl01\\Desktop\\Sikuli-ModelOffice0_Release\\newbie.csv")
xReader.readline()
for line in xReader:
   (ref, val) = eval(''.join(('[', line.strip(), ']')))
   if (Ref == "Smoker"):
       Settings.Smoker = Val
   if (Ref == "Gender"):
       Settings.Gender = Val
   if (Ref == "Marital"):
       Settings.Marital = Val
   if (Ref == "Forename"):
       Settings.Forename = Val
   if (Ref == "DOB"):
       Settings.DOB = Val      
print Settings.Smoker
print Settings.Gender
print Settings.Marital
print Settings.Forename
print Settings.DOB
---------------------------------------------------------
newbie.csv file
---------------------------------------------------------
Smoker,n
Gender,m
Marital,s
Forename,Test
DOB,t-50y

---------------------------------------------------------
Error Message
---------------------------------------------------------
[error] An error occurs at line 5
[error] Error message: Traceback (most recent call last):
 File "C:\Users\davidl01\AppData\Local\Temp\sikuli-tmp1905465301904626220.py", line 5, in 
 (ref, val) = eval(''.join(('[', line.strip(), ']')))
 File "", line 1, in 
NameError: name 'Gender' is not defined

---------------------------------------------------------
Before people ask, I've made sure the files are all in the correct place etc and saved in the .CSV format.
If I'm being a tool don't hold back, otherwise I won't learn. :)
Thanks,
Dave

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.