← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #234093]: Is there a way to create a new CSV file, then write to specific cells

 

Question #234093 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/234093

    Status: Open => Answered

Eugene S proposed the following answer:
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()

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