{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport jsonlines","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-11-13T15:48:59.304591Z","iopub.execute_input":"2022-11-13T15:48:59.306167Z","iopub.status.idle":"2022-11-13T15:48:59.330633Z","shell.execute_reply.started":"2022-11-13T15:48:59.305629Z","shell.execute_reply":"2022-11-13T15:48:59.329462Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ntest_list=[]\nn=1\n\ntest_list=[]\n#Iterate over the json files\nwith jsonlines.open('/kaggle/input/otto-recommender-system/train.jsonl') as reader:\n    #Iterate over the each line on the reader via enumerate\n    for idx, result in enumerate(reader):\n        \n        for event in result['events']:\n            test_list.append((result['session'], event['aid'], event['ts'], event['type']))\n        #print(f\"result: {result['session']}\")\n        #print(isinstance(result, dict))\n        if n%1000000==0:\n            print(n)\n        if n%2000000==0:\n            test=pd.DataFrame(test_list, columns=['session', 'aid', 'ts', 'type'])\n            test.to_csv('train_'+str(n)+'.csv', index=False)\n            test_list=[]  \n        n+=1\n","metadata":{"execution":{"iopub.status.busy":"2022-11-13T15:53:21.820086Z","iopub.execute_input":"2022-11-13T15:53:21.820597Z","iopub.status.idle":"2022-11-13T15:53:21.827126Z","shell.execute_reply.started":"2022-11-13T15:53:21.820532Z","shell.execute_reply":"2022-11-13T15:53:21.825991Z"},"trusted":true},"execution_count":null,"outputs":[]}]}