Wednesday, 28 August 2013

how to handle with string while writing in csv file with python

how to handle with string while writing in csv file with python

i'm trying to write in csv file i have two value in my list [string,int]
and this is my code
prod = [['Enveloppes Esquisse adh\xe9sives', 1.85],
['Enveloppes adh\xe9sives Esquisse', 1.1],
['Enveloppes adh\xe9sives Esquisse', 1.1],
['Enveloppes adh\xe9sives Esquisse', 1.85],
['Pochettes kraft Esquisse', 0.95],
['Pochettes kraft Esquisse', 1.75]]
cw = csv.writer(open("nv.csv", 'w'), delimiter=';')
cw.writerow(['Produit', 'Prix'])
for row in prod:
cw.writerow( [row[0],row[1]] )
but i get 'enveloppes' in row then esquisse in other row not all the
string in one row can anyone help me ? my csv file should contain two
rows, one for 'Enveloppes Esquisse adh\xe9sives' and one for '1,85'

No comments:

Post a Comment