mygeekdaddy
Feb 21, 2014 - 02:04
I'm trying to take a comma separated text block from the clipboard and convert it to a CSV file. A sample text that I'm using in test looks like this:
apple, orange, pear
bread , donut, bagel
car, toy, truck
My current script is supposed to read the text from the clipboard and create a CSV file:
import csv
import clipboard
data = clipboard.get()
f = open('cv_data.csv', 'wb')
w = csv.writer(f, delimiter = ',')
w.writerow(data.split(','))
f.close()
I get the file to write, but the output from the script ends up being this:
apple, orange," pear
bread", donut," bagel
car", toy, truck
Any suggestions on what I can do differently to not get the extra quotes in the output file?