I want to write a code which can create "mydata.csv" file, (python execution should pause here) write values into "mydata.csv", after closing "mydata.csv" python code execution should resume.
fd = open('your_file', 'w')
# code which does other stuff
# now we have new data, write it
fd.write(data)
# code
# close the file descriptor before your program exits
fd.close()