469,289 Members | 2,247 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

Python from list to CSV. how to strip unico de chars from results. decide function on

I nave some data get in json anḍ to convertito to CSV.
I m not able to strip ,u'value', iwriting on CSV.
This is the code
Expand|Select|Wrap|Line Numbers
  1. extractwr = csv.writer(myfile)  
  2. for x in range :
  3.  g=str(d[n].values()).strip("{}").split(",")
  4.  repr(g).decode("unicode_escape").encode("utf-8")
  5.  wr.writerow(g)
  6.  n=n+1
  7. myfile.close()
But I get this..
[u'\u20ac 1.195,03', u'22', 22.0, 1.0, u'1', u'EUR', u'EUR', 1195.03, u'\u20ac 1.195,03', 1195.03]
[u'\u20ac 290,36', u'22', 22.0, 0.0, u'0', u'EUR', 290.36]

How to solve?
Mar 20 '15 #1
1 1473
bvdet
2,851 Expert Mod 2GB
Your code will fail at the start of the for loop. Function range has no argument.
Expand|Select|Wrap|Line Numbers
  1. >>> for x in range :
  2. ...     print "XX"
  3. ...     
  4. Traceback (most recent call last):
  5.   File "<interactive input>", line 1, in <module>
  6. TypeError: 'builtin_function_or_method' object is not iterable
  7. >>> 
Mar 21 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Dave Brueck | last post: by
1 post views Thread by Dave Brueck | last post: by
3 posts views Thread by Brad Clements | last post: by
reply views Thread by Heiko Wundram | last post: by
4 posts views Thread by Michael Tobis | last post: by
reply views Thread by Chris | last post: by
9 posts views Thread by Terry Reedy | last post: by
8 posts views Thread by jerry.levan | last post: by
1 post views Thread by Tom Stambaugh | last post: by
reply views Thread by Gareth Owen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.