Is there a way to create a new CSV file, then write to specific cells

Asked by Benjamin Bruffey

So I would like to know if certain stages of my GUI testing are successful (i.e. if an element displayed correctly, record a pass)
I am currently doing this with .txt files but this is clunky and hard to read. I would like to be able to create a .CSV file and then input data into specific cells, so for example I would want to input "Field 1 Validation Check" into cell [1][1] then in cell [1][2] i would like to input pass or fail. Anyone help on this is appreciated!

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Eugene S (shragovich) said :
#1

Hey there,

It sounds more like a Python question rather than Sikuli :)

You can use CSV module, which is a part of Python Standard Library. The usage is explained here:
http://docs.python.org/2/library/csv.html

Other option is to something like fileinput or regular string manipulation tools, for example:

for line in fileinput.input(fileName, inplace = True):
  elements = re.split(",", line)

  testNameElement = elements[0]
  matched = re.match(matchPattern, testNameElement, flags=0)

  if (matched != None): #If a match was found
   print "%s,%d,%s" % (testName, failStatus, st) #This will rewrite the line with matching value (with whatever is inside the print)
  else:
   print line, #This will leave the line unchanged. The comma prevents creating new line

fileinput.close()

Revision history for this message
Techno.Scavenger (techno-scavenger) said :
#2

You can also use elementTree to parse/manipulate/update xml file.

Another option is to use zxJDBC. I have found a way to make this work in Sikuli IDE using MS SQL Server.

Can you help with this problem?

Provide an answer of your own, or ask Benjamin Bruffey for more information if necessary.

To post a message you must log in.