我有一个包含推文的巨大文件,不幸的是,一些推文的情绪api格式不受支持。我想跳过这些推文并继续上传休息并获得回复。我想我陷入了无限循环。帮助我!
我怎么知道推文是否有错误?据我所知,没有回应是它的指标,所以这条线是正确的
if (indicoio.emotion(row))=='FALSE':
import indicoio
import csv
import json
import itertools
indicoio.config.api_key = 'key'
json_file = open("xaa31.json", "w")
x=1
with open('output3.csv', 'r') as csvfile:
so = csv.reader(csvfile)
while x < 12001:
for (row=[x]) in so:
if (indicoio.emotion(row))=='FALSE':
print x
x+=1
else:
# print (indicoio.emotion(row))
jsonout=indicoio.emotion(row)
json.dump(jsonout, json_file, indent=2)
json_file.write(",\n")
x+=1
json_file.close()
print 'done'