By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,966 Members | 2,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,966 IT Pros & Developers. It's quick & easy.

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

P: 1
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
Share this Question
Share on Google+
1 Reply


bvdet
Expert Mod 2.5K+
P: 2,851
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.