from__future__importprint_functionimportpickleimportpandasaspddefto_df(file_path):withopen(file_path,'r')asfin:df={}i=0forlineinfin:df[i]=eval(line)i+=1df=pd.DataFrame.from_dict(df,orient='index')returndfprint("start to analyse reviews_Electronics_5.json")reviews_df=to_df('./raw_data/reviews_Electronics_5.json')withopen('./raw_data/reviews.pkl','wb')asf:pickle.dump(reviews_df,f,pickle.HIGHEST_PROTOCOL)print("start to analyse meta_Electronics.json")meta_df=to_df('./raw_data/meta_Electronics.json')meta_df=meta_df[meta_df['asin'].isin(reviews_df['asin'].unique())]meta_df=meta_df.reset_index(drop=True)withopen('./raw_data/meta.pkl','wb')asf:pickle.dump(meta_df,f,pickle.HIGHEST_PROTOCOL)