SHARE
TWEET

Untitled

a guest Aug 20th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a,b,d,f,e,2014-09-16T01:57:48.295Z,2017-07-13T02:01:03.059Z
  2. s,d,fe,r,t,2014-09-17T01:57:48.295Z,2017-07-23T02:01:03.059Z
  3. wa,db,td,yf,de,2013-09-26T01:57:48.295Z,2017-07-13T02:01:03.059Z
  4. aws,dedr,tgyfe,juir,ttt,2018-09-17T01:57:48.295Z,2017-07-23T02:01:03.059Z
  5.      
  6. # load json in panda dataframe
  7. # parses through the json (normalize)
  8. # filter required columns and write into .csv file
  9. # remove the index field (first column)
  10.  
  11.  
  12. def conversion():
  13.     data_set = pd.read_json("/a/b/c.json")
  14.     normalized_data = json_normalize(data_set['data'])
  15.     new_data=pd.DataFrame(normalized_data['data'].values.tolist())
  16.     filtered_data = new_data[["f1","f2","f3","f4","f5","date1","date2"]]
  17.     filtered_data.to_csv("/a/b/c/file1.csv",index=False)
  18.  
  19. conversion()
  20.      
  21. a,b,d,f,e,2014-09-16 01:57:48,2017-07-13 02:01:03
  22. s,d,fe,r,t,2014-09-17 01:57:48,2017-07-23 02:01:03
  23. wa,db,td,yf,de,2013-09-26 01:57:48,2017-07-13 02:01:03
  24. aws,dedr,tgyfe,juir,ttt,2018-09-17 01:57:48,2017-07-23 02:01:03
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top