Reputation: 83
I am trying to use a CSV file to store some data. This code creates the file:
with open('keras_character_W.csv', 'w') as csvFile:
fieldnames = ['images', 'result_character']
writer = csv.DictWriter(csvFile, fieldnames=fieldnames)
writer.writeheader()
later, when I am read to store the variables, a command 's' stores them:
state = cv2.waitKey(0)
if state == ord('q'):
break
elif state == ord('s'):
writer.writerow({'images': ' '})
writer.writerow({'images': 'guess_right = ', 'result_character': x, })
writer.writerow({'images': 'final = ', 'result_character': y , })
but the CSV file is empty.
"I checked the caps and if the condition satisfied but didn't find anything the file even open on text editor not excel program "
Upvotes: 0
Views: 119
Reputation: 20500
It is a bit unclear from your example, but I think you are closing the CSV early.
When you do with open('keras_character_W.csv', 'w') as csvFile:
, you start a context in which:
keras_character_W.csv
are erasedwith
statement, meaning you stop indenting.Hope this helps!
Keep hacking! Keep notes.
Upvotes: 1