JJuOn

Pass UnicodeEncodeError

...@@ -23,11 +23,11 @@ def setup(): ...@@ -23,11 +23,11 @@ def setup():
23 23
24 def save(df,path='problems.csv'): 24 def save(df,path='problems.csv'):
25 print('Saving to {}...'.format(path),end='') 25 print('Saving to {}...'.format(path),end='')
26 - df.to_csv(path) 26 + df.to_csv(path,encoding='utf-8-sig')
27 print('Done.') 27 print('Done.')
28 28
29 def load(path='problems.csv'): 29 def load(path='problems.csv'):
30 - problems=pd.read_csv(path,index_col=0) 30 + problems=pd.read_csv(path,index_col=0,encoding='utf-8-sig')
31 return problems 31 return problems
32 32
33 def get_khu_problem_list(): 33 def get_khu_problem_list():
...@@ -119,11 +119,15 @@ def get_category(problems): ...@@ -119,11 +119,15 @@ def get_category(problems):
119 problemListLen=len(problemList) 119 problemListLen=len(problemList)
120 for problemNum in problems['problemNum'].values: 120 for problemNum in problems['problemNum'].values:
121 if idx<problemListLen and int(problemList[idx]['id'])==int(problemNum): 121 if idx<problemListLen and int(problemList[idx]['id'])==int(problemNum):
122 + try:
122 category=json.loads(problems.loc[problems.problemNum==problemNum,'category'].values[0]) 123 category=json.loads(problems.loc[problems.problemNum==problemNum,'category'].values[0])
123 category.append(tag['full_name_ko']) 124 category.append(tag['full_name_ko'])
124 problems.loc[problems.problemNum==problemNum,'category']=json.dumps(category,ensure_ascii=False) 125 problems.loc[problems.problemNum==problemNum,'category']=json.dumps(category,ensure_ascii=False)
125 idx+=1 126 idx+=1
126 print('Problem {} in category {}'.format(problemNum,tag['full_name_ko'])) 127 print('Problem {} in category {}'.format(problemNum,tag['full_name_ko']))
128 + except UnicodeEncodeError:
129 + print('Error occured in {}'.format(problemNum),file=sys.stderr)
130 + pass
127 save(problems,SAVE_PATH) 131 save(problems,SAVE_PATH)
128 return problems 132 return problems
129 133
......