So, I just started mining twitter data using its python twitter api.
And was about to plot the tweet stucture
But I am getting this error
f.write('strict digraph {\n%s\n}' % (';\n'.join(dot),))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 108:
ordinal not in range(128)
This is the code..
def draw_tweet_graph(g):
OUT = "graph.dot"
try:
nx.drawing.write_dot(g, OUT)
except ImportError, e:
dot = ['"%s" -> "%s" [tweet_id=%s]' % (n1, n2, g[n1][n2]['tweet_id']) \
for n1, n2 in g.edges()]
f = open(OUT, 'w')
f.write('strict digraph {\n%s\n}' % (';\n'.join(dot),))
f.close()
You want
codecs.open()for your file.