Reputation: 411
I want to remove the pound sign (£
) from a csv file
f = open('menu.csv')
content = f.read()
content.decode("utf-8")
print content
content.decode("utf-8").replace(u"\u00a3", "*")
content.decode("utf-8").replace(u"\u00a3", "*").encode("utf-8")
But when I print it, content doesn't change at all. It returns the same string.
Upvotes: 1
Views: 2065
Reputation: 5658
to print pound sign you should open file with encodigns flag ..
with open('data.csv', encoding='utf-8') as f:
Upvotes: 0
Reputation: 44828
You don't need this encoding/decoding business:
content=content.encode('utf-8').replace(u'£','*')
Upvotes: 0
Reputation: 67968
Update your content
content=content.decode("utf-8").replace(u"\u00a3", "*")
Upvotes: 2