{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os\n\ncolumns = ['mag_x','mag_y', 'mag_z','mag_u_x','mag_u_y', 'mag_u_z', 'tx', 'ty']\ntrain = pd.DataFrame(columns=columns)\n\nfor dirname, _, filenames in os.walk('/kaggle/input/indoor-location-navigation/train/'):\n    for filename in filenames:\n        #print(os.path.join(dirname, filename))\n        df = pd.read_csv(os.path.join(dirname, filename), header = None)\n        df['new']=df[0].str.replace('\\t',',')\n        df.drop(df.columns[0],axis=1,inplace=True)\n        #waypoint is row 7\n        waypoint=df.iloc[7].values\n        \n        #mag is row 9\n        mag_cal=df.iloc[9].values\n    \n        #TYPE_MAGNETIC_FIELD_UNCALIBRATED\n        mag_uncal=df.iloc[12].values\n\n        waypoint.tolist()\n        mag_uncal.tolist()\n        mag_cal.tolist()\n\n        way=waypoint[0].split(',')\n        mag1=mag_cal[0].split(',')\n        mag2=mag_uncal[0].split(',')\n        if mag2[2].isalnum()==False:\n            try:\n                to_append=mag1[2],mag1[3],mag1[4],mag2[2],mag2[3],mag2[4],way[2],way[3]\n            except IndexError:\n                print('index error')\n            else:\n                df_length = len(train)\n                train.loc[df_length] = to_append\n                print (mag1[2],mag1[3],mag1[4],mag2[2],mag2[3],mag2[4],way[2],way[3])\n                train.to_csv('train_waypoints.csv', index = False)\n                ","execution_count":null,"outputs":[]}],"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":4,"nbformat_minor":4}