How to sort players to teams - python

I have a json with players and teams. They are completly random like:
Now, i want to sort them based on their "team".
I've read the docs and I'm completely confused and don't understand much.
{'puuid': '6bec3c19-6150-57e8-ba84-16220ab49198', 'name': 'Navis', 'tag': 'Games', 'team': 'Red', 'level': 110, 'character': 'Chamber', 'currenttier': 12, 'currenttier_patched': 'Gold 1', 'player_card': '1b6c643b-4f7e-aed8-88f6-f3932e682c14', 'player_title': 'a030f8ac-4475-d8d0-53a1-b8aafd5a3546', 'party_id': '578c7ad5-0eb1-4e6e-ab99-ecf971902cab', 'session_playtime': {'minutes': 231, 'seconds': 13860, 'milliseconds': 13860000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19043.1.256.64bit'}}, 'ability_casts': {'c_cast': 14, 'q_cast': 3, 'e_cast': 1, 'x_cast': 2}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/1b6c643b-4f7e-aed8-88f6-f3932e682c14/smallart.png', 'large': 'https://media.valorant-api.com/playercards/1b6c643b-4f7e-aed8-88f6-f3932e682c14/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/1b6c643b-4f7e-aed8-88f6-f3932e682c14/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/killfeedportrait.png'}}, 'stats': {'score': 1895, 'kills': 7, 'deaths': 15, 'assists': 2, 'bodyshots': 33, 'headshots': 1, 'legshots': 1}, 'economy': {'spent': {'overall': 43150, 'average': 2697}, 'loadout_value': {'overall': 52850, 'average': 3303}}, 'damage_made': 1114, 'damage_received': 2507}
{'puuid': '1446ff0a-9c8a-5cc6-af55-81bf6612a99b', 'name': 'Taha', 'tag': 'Yoru', 'team': 'Red', 'level': 95, 'character': 'Neon', 'currenttier': 13, 'currenttier_patched': 'Gold 2', 'player_card': '5b025468-4810-96e1-d19d-2ea35074586c', 'player_title': 'd13e579c-435e-44d4-cec2-6eae5a3c5ed4', 'party_id': '9d856301-1397-4e6a-b580-cff409a67ab1', 'session_playtime': {'minutes': 154, 'seconds': 9240, 'milliseconds': 9240000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.22000.1.256.64bit'}}, 'ability_casts': {'c_cast': 3, 'q_cast': 0, 'e_cast': 15, 'x_cast': 0}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/smallart.png', 'large': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/bb2a4828-46eb-8cd1-e765-15848195d751/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/bb2a4828-46eb-8cd1-e765-15848195d751/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/bb2a4828-46eb-8cd1-e765-15848195d751/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/bb2a4828-46eb-8cd1-e765-15848195d751/killfeedportrait.png'}}, 'stats': {'score': 1132, 'kills': 4, 'deaths': 16, 'assists': 1, 'bodyshots': 15, 'headshots': 5, 'legshots': 0}, 'economy': {'spent': {'overall': 40200, 'average': 2513}, 'loadout_value': {'overall': 45900, 'average': 2869}}, 'damage_made': 542, 'damage_received': 2326}
{'puuid': 'be2b3d3a-7281-5fb8-9b9a-61475111a8b0', 'name': 'YourLocalSkye', 'tag': 'M1lf', 'team': 'Blue', 'level': 99, 'character': 'Chamber', 'currenttier': 15, 'currenttier_patched': 'Platinum 1', 'player_card': '22a21e81-4b57-061f-d56f-aea3c4a8bf33', 'player_title': '631f4283-48b1-1855-d646-5e8f80e29821', 'party_id': 'c0ca03d6-dbf4-495a-9444-a50da9b2b5b3', 'session_playtime': {'minutes': 12, 'seconds': 720, 'milliseconds': 720000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.256.64bit'}}, 'ability_casts': {'c_cast': 14, 'q_cast': 5, 'e_cast': 38, 'x_cast': 1}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/22a21e81-4b57-061f-d56f-aea3c4a8bf33/smallart.png', 'large': 'https://media.valorant-api.com/playercards/22a21e81-4b57-061f-d56f-aea3c4a8bf33/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/22a21e81-4b57-061f-d56f-aea3c4a8bf33/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/killfeedportrait.png'}}, 'stats': {'score': 4402, 'kills': 18, 'deaths': 10, 'assists': 3, 'bodyshots': 23, 'headshots': 11, 'legshots': 1}, 'economy': {'spent': {'overall': 35200, 'average': 2200}, 'loadout_value': {'overall': 55100, 'average': 3444}}, 'damage_made': 2724, 'damage_received': 1904}
{'puuid': 'c3a09504-4c30-520a-b1c6-00b95a35a127', 'name': 'FAST TECH YT', 'tag': '11111', 'team': 'Red', 'level': 159, 'character': 'KAY/O', 'currenttier': 14, 'currenttier_patched': 'Gold 3', 'player_card': 'f67a7c8f-4d3f-b76f-2921-478a4da44109', 'player_title': 'a030f8ac-4475-d8d0-53a1-b8aafd5a3546', 'party_id': '563d54bf-b56e-4c17-a771-cb69c02ab164', 'session_playtime': {'minutes': 2, 'seconds': 120, 'milliseconds': 120000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19042.1.256.64bit'}}, 'ability_casts': {'c_cast': 3, 'q_cast': 7, 'e_cast': 21, 'x_cast': 2}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/f67a7c8f-4d3f-b76f-2921-478a4da44109/smallart.png', 'large': 'https://media.valorant-api.com/playercards/f67a7c8f-4d3f-b76f-2921-478a4da44109/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/f67a7c8f-4d3f-b76f-2921-478a4da44109/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/601dbbe7-43ce-be57-2a40-4abd24953621/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/601dbbe7-43ce-be57-2a40-4abd24953621/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/601dbbe7-43ce-be57-2a40-4abd24953621/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/601dbbe7-43ce-be57-2a40-4abd24953621/killfeedportrait.png'}}, 'stats': {'score': 4180, 'kills': 14, 'deaths': 15, 'assists': 4, 'bodyshots': 41, 'headshots': 11, 'legshots': 1}, 'economy': {'spent': {'overall': 39200, 'average': 2450}, 'loadout_value': {'overall': 45850, 'average': 2866}}, 'damage_made': 2838, 'damage_received': 2466}
{'puuid': 'fd976800-eaa4-50ab-8d77-f2ba11ee2334', 'name': 'twitch otisvn', 'tag': 'EUW', 'team': 'Blue', 'level': 87, 'character': 'Viper', 'currenttier': 12, 'currenttier_patched': 'Gold 1', 'player_card': 'eac64718-4956-31ef-2c95-8b85e93d7fcc', 'player_title': 'd13e579c-435e-44d4-cec2-6eae5a3c5ed4', 'party_id': '9fff883f-0eb4-4c67-8621-f2f4fbf7d4cc', 'session_playtime': {'minutes': 4, 'seconds': 240, 'milliseconds': 240000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.768.64bit'}}, 'ability_casts': {'c_cast': 4, 'q_cast': 3, 'e_cast': 15, 'x_cast': 2}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/eac64718-4956-31ef-2c95-8b85e93d7fcc/smallart.png', 'large': 'https://media.valorant-api.com/playercards/eac64718-4956-31ef-2c95-8b85e93d7fcc/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/eac64718-4956-31ef-2c95-8b85e93d7fcc/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/707eab51-4836-f488-046a-cda6bf494859/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/707eab51-4836-f488-046a-cda6bf494859/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/707eab51-4836-f488-046a-cda6bf494859/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/707eab51-4836-f488-046a-cda6bf494859/killfeedportrait.png'}}, 'stats': {'score': 3051, 'kills': 14, 'deaths': 6, 'assists': 5, 'bodyshots': 31, 'headshots': 7, 'legshots': 5}, 'economy': {'spent': {'overall': 23700, 'average': 1481}, 'loadout_value': {'overall': 53300, 'average': 3331}}, 'damage_made': 1836, 'damage_received': 1093}
{'puuid': '4bc6d87f-7a7f-5fa2-a194-b3550e7768da', 'name': 'Sasha', 'tag': '4444', 'team': 'Blue', 'level': 72, 'character': 'Raze', 'currenttier': 14, 'currenttier_patched': 'Gold 3', 'player_card': '4dce4142-44bf-32e5-6f51-7e905389502c', 'player_title': '86bd997d-4e37-18c9-ada0-bf92e54baf60', 'party_id': '88353d38-c1bf-48a1-b943-ecced68711d4', 'session_playtime': {'minutes': 85, 'seconds': 5100, 'milliseconds': 5100000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.256.64bit'}}, 'ability_casts': {'c_cast': 12, 'q_cast': 7, 'e_cast': 8, 'x_cast': 1}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/4dce4142-44bf-32e5-6f51-7e905389502c/smallart.png', 'large': 'https://media.valorant-api.com/playercards/4dce4142-44bf-32e5-6f51-7e905389502c/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/4dce4142-44bf-32e5-6f51-7e905389502c/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/f94c3b30-42be-e959-889c-5aa313dba261/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/f94c3b30-42be-e959-889c-5aa313dba261/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/f94c3b30-42be-e959-889c-5aa313dba261/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/f94c3b30-42be-e959-889c-5aa313dba261/killfeedportrait.png'}}, 'stats': {'score': 5759, 'kills': 17, 'deaths': 11, 'assists': 9, 'bodyshots': 54, 'headshots': 10, 'legshots': 7}, 'economy': {'spent': {'overall': 50750, 'average': 3172}, 'loadout_value': {'overall': 67900, 'average': 4244}}, 'damage_made': 3512, 'damage_received': 2096}
{'puuid': 'd0a6c5fa-5094-5650-9b56-8154d3191725', 'name': 'EnzoNezo', 'tag': '3319', 'team': 'Blue', 'level': 101, 'character': 'Sage', 'currenttier': 12, 'currenttier_patched': 'Gold 1', 'player_card': '5b025468-4810-96e1-d19d-2ea35074586c', 'player_title': '5bdea980-4397-a1bd-1fab-659153ca196e', 'party_id': '33ca0f84-e3b0-4d28-8ae6-f6cda948db72', 'session_playtime': {'seconds': None, 'milliseconds': None}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.256.64bit'}}, 'ability_casts': {'c_cast': 8, 'q_cast': 9, 'e_cast': 4, 'x_cast': 1}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/smallart.png', 'large': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/killfeedportrait.png'}}, 'stats': {'score': 2738, 'kills': 8, 'deaths': 12, 'assists': 12, 'bodyshots': 39, 'headshots': 5, 'legshots': 19}, 'economy': {'spent': {'overall': 54150, 'average': 3384}, 'loadout_value': {'overall': 66200, 'average': 4138}}, 'damage_made': 1591, 'damage_received': 2199}
{'puuid': '70f7373a-ba78-5c9a-a963-767fbf27d9ad', 'name': 'Road2Radaint', 'tag': '6667', 'team': 'Red', 'level': 22, 'character': 'Jett', 'currenttier': 12, 'currenttier_patched': 'Gold 1', 'player_card': '9fb348bc-41a0-91ad-8a3e-818035c4e561', 'player_title': 'dd66cdcb-46cb-5e6e-f66f-51aa8cc3c14b', 'party_id': '578c7ad5-0eb1-4e6e-ab99-ecf971902cab', 'session_playtime': {'minutes': 2, 'seconds': 120, 'milliseconds': 120000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.256.64bit'}}, 'ability_casts': {'c_cast': 6, 'q_cast': 2, 'e_cast': 16, 'x_cast': 2}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/9fb348bc-41a0-91ad-8a3e-818035c4e561/smallart.png', 'large': 'https://media.valorant-api.com/playercards/9fb348bc-41a0-91ad-8a3e-818035c4e561/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/9fb348bc-41a0-91ad-8a3e-818035c4e561/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/add6443a-41bd-e414-f6ad-e58d267f4e95/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/add6443a-41bd-e414-f6ad-e58d267f4e95/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/add6443a-41bd-e414-f6ad-e58d267f4e95/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/add6443a-41bd-e414-f6ad-e58d267f4e95/killfeedportrait.png'}}, 'stats': {'score': 4271, 'kills': 12, 'deaths': 15, 'assists': 6, 'bodyshots': 32, 'headshots': 11, 'legshots': 3}, 'economy': {'spent': {'overall': 35100, 'average': 2194}, 'loadout_value': {'overall': 50900, 'average': 3181}}, 'damage_made': 2682, 'damage_received': 2678}
{'puuid': '1ccd31a8-6109-5edd-bd58-bb90f3b55a1d', 'name': 'E S Q U I', 'tag': '1234', 'team': 'Red', 'level': 61, 'character': 'Fade', 'currenttier': 12, 'currenttier_patched': 'Gold 1', 'player_card': '39729022-445a-d7bb-52e7-9e909e481db2', 'player_title': '025b0aaf-4bc6-522c-faae-a484779c5d03', 'party_id': '51217228-3efc-42f5-9aac-9ef20835a09b', 'session_playtime': {'minutes': 83, 'seconds': 4980, 'milliseconds': 4980000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.256.64bit'}}, 'ability_casts': {'c_cast': 10, 'q_cast': 6, 'e_cast': 14, 'x_cast': 2}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/39729022-445a-d7bb-52e7-9e909e481db2/smallart.png', 'large': 'https://media.valorant-api.com/playercards/39729022-445a-d7bb-52e7-9e909e481db2/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/39729022-445a-d7bb-52e7-9e909e481db2/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/dade69b4-4f5a-8528-247b-219e5a1facd6/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/dade69b4-4f5a-8528-247b-219e5a1facd6/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/dade69b4-4f5a-8528-247b-219e5a1facd6/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/dade69b4-4f5a-8528-247b-219e5a1facd6/killfeedportrait.png'}}, 'stats': {'score': 2287, 'kills': 8, 'deaths': 15, 'assists': 0, 'bodyshots': 17, 'headshots': 4, 'legshots': 2}, 'economy': {'spent': {'overall': 43000, 'average': 2688}, 'loadout_value': {'overall': 47750, 'average': 2984}}, 'damage_made': 1382, 'damage_received': 2424}
{'puuid': '55ac8119-1247-517d-85fb-5134a957d8df', 'name': 'Menzirs', 'tag': '9042', 'team': 'Blue', 'level': 81, 'character': 'Skye', 'currenttier': 14, 'currenttier_patched': 'Gold 3', 'player_card': '4ca63988-4ca6-2911-a1b5-98a4b765dffd', 'player_title': '39374ca0-447b-1d4e-aa38-e6b0e0b07946', 'party_id': '5c59434c-7a64-4736-956c-e35038aaabeb', 'session_playtime': {'minutes': 183, 'seconds': 10980, 'milliseconds': 10980000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.768.64bit'}}, 'ability_casts': {'c_cast': 4, 'q_cast': 5, 'e_cast': 26, 'x_cast': 3}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/4ca63988-4ca6-2911-a1b5-98a4b765dffd/smallart.png', 'large': 'https://media.valorant-api.com/playercards/4ca63988-4ca6-2911-a1b5-98a4b765dffd/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/4ca63988-4ca6-2911-a1b5-98a4b765dffd/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/6f2a04ca-43e0-be17-7f36-b3908627744d/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/6f2a04ca-43e0-be17-7f36-b3908627744d/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/6f2a04ca-43e0-be17-7f36-b3908627744d/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/6f2a04ca-43e0-be17-7f36-b3908627744d/killfeedportrait.png'}}, 'stats': {'score': 4217, 'kills': 19, 'deaths': 6, 'assists': 7, 'bodyshots': 35, 'headshots': 12, 'legshots': 0}, 'economy': {'spent': {'overall': 32700, 'average': 2044}, 'loadout_value': {'overall': 67900, 'average': 4244}}, 'damage_made': 2573, 'damage_received': 1422}
This is only a part of the JSON which is neccessary to my Question. The other part of the JSON is way longer.

Use the sorted function, with the key as the 'team' value.
data = json.load(open('filepath.json'))
result = sorted(data, key=lambda x: x['team'])

Related

Not able to parse JSON data from text file using python script

I have a '.txt' file that contains JSON data like below.
[{'tradable': True, 'mode': 'full', 'instrument_token': 4708097, 'last_price': 178.65, 'last_traded_quantity': 5, 'average_traded_price': 180.1, 'volume_traded': 4581928, 'total_buy_quantity': 1282853, 'total_sell_quantity': 1673842, 'ohlc': {'open': 181.95, 'high': 181.95, 'low': 177.8, 'close': 181.0}, 'change': -1.2983425414364609, 'last_trade_time': datetime.datetime(2023, 1, 12, 13, 4, 58), 'oi': 0, 'oi_day_high': 0, 'oi_day_low': 0, 'exchange_timestamp': datetime.datetime(2023, 1, 12, 13, 5, 1), 'depth': {'buy': [{'quantity': 653, 'price': 178.6, 'orders': 8}, {'quantity': 2408, 'price': 178.55, 'orders': 15}, {'quantity': 6329, 'price': 178.5, 'orders': 22}, {'quantity': 9161, 'price': 178.45, 'orders': 24}, {'quantity': 7775, 'price': 178.4, 'orders': 17}], 'sell': [{'quantity': 5726, 'price': 178.7, 'orders': 8}, {'quantity': 4099, 'price': 178.75, 'orders': 11}, {'quantity': 23951, 'price': 178.8, 'orders': 25}, {'quantity': 7446, 'price': 178.85, 'orders': 21}, {'quantity': 11379, 'price': 178.9, 'orders': 21}]}}, {'tradable': True, 'mode': 'full', 'instrument_token': 871681, 'last_price': 972.55, 'last_traded_quantity': 1, 'average_traded_price': 973.85, 'volume_traded': 411290, 'total_buy_quantity': 152925, 'total_sell_quantity': 214765, 'ohlc': {'open': 971.75, 'high': 978.6, 'low': 969.0, 'close': 967.75}, 'change': 0.4959958667011061, 'last_trade_time': datetime.datetime(2023, 1, 12, 13, 4, 53), 'oi': 0, 'oi_day_high': 0, 'oi_day_low': 0, 'exchange_timestamp': datetime.datetime(2023, 1, 12, 13, 5, 4), 'depth': {'buy': [{'quantity': 6, 'price': 972.15, 'orders': 2}, {'quantity': 3, 'price': 972.1, 'orders': 2}, {'quantity': 15, 'price': 972.05, 'orders': 3}, {'quantity': 455, 'price': 972.0, 'orders': 16}, {'quantity': 14, 'price': 971.95, 'orders': 2}], 'sell': [{'quantity': 6, 'price': 972.5, 'orders': 3}, {'quantity': 49, 'price': 972.55, 'orders': 2}, {'quantity': 10, 'price': 972.6, 'orders': 1}, {'quantity': 27, 'price': 972.65, 'orders': 2}, {'quantity': 10, 'price': 972.7, 'orders': 1}]}}]
This data was written to a .txt file after it was recieved from zerodha websocket. Now, I want to read the data from the .txt file using my python script and want to load it as a json. But the json.loads() method in python throws the below error.
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
I have tried eval and ast.literal_eval methods in python as well but it didn't solve my problem. All I want is to be able to read the above data as a JSON to my python script. Any leads would be of great help.
Let me start off with THIS IS A BAD IDEA.
The comments on the question call out that this is not a JSON object in a file, rather the result of some other Python process printing the result and putting that in a file. The correct solution would be to modify the producer to use json.dumps() instead.
That aside, here's a DANGEROUS way to read that source file into a Python object.
import datetime # needed for `eval()`
with open('textfile.txt', 'r') as f:
data = eval(f.read())
from pprint import pprint
pprint(data)
This will produce the following output from that input:
[{'average_traded_price': 180.1,
'change': -1.2983425414364609,
'depth': {'buy': [{'orders': 8, 'price': 178.6, 'quantity': 653},
{'orders': 15, 'price': 178.55, 'quantity': 2408},
{'orders': 22, 'price': 178.5, 'quantity': 6329},
{'orders': 24, 'price': 178.45, 'quantity': 9161},
{'orders': 17, 'price': 178.4, 'quantity': 7775}],
'sell': [{'orders': 8, 'price': 178.7, 'quantity': 5726},
{'orders': 11, 'price': 178.75, 'quantity': 4099},
{'orders': 25, 'price': 178.8, 'quantity': 23951},
{'orders': 21, 'price': 178.85, 'quantity': 7446},
{'orders': 21, 'price': 178.9, 'quantity': 11379}]},
'exchange_timestamp': datetime.datetime(2023, 1, 12, 13, 5, 1),
'instrument_token': 4708097,
'last_price': 178.65,
'last_trade_time': datetime.datetime(2023, 1, 12, 13, 4, 58),
'last_traded_quantity': 5,
'mode': 'full',
'ohlc': {'close': 181.0, 'high': 181.95, 'low': 177.8, 'open': 181.95},
'oi': 0,
'oi_day_high': 0,
'oi_day_low': 0,
'total_buy_quantity': 1282853,
'total_sell_quantity': 1673842,
'tradable': True,
'volume_traded': 4581928},
{'average_traded_price': 973.85,
'change': 0.4959958667011061,
'depth': {'buy': [{'orders': 2, 'price': 972.15, 'quantity': 6},
{'orders': 2, 'price': 972.1, 'quantity': 3},
{'orders': 3, 'price': 972.05, 'quantity': 15},
{'orders': 16, 'price': 972.0, 'quantity': 455},
{'orders': 2, 'price': 971.95, 'quantity': 14}],
'sell': [{'orders': 3, 'price': 972.5, 'quantity': 6},
{'orders': 2, 'price': 972.55, 'quantity': 49},
{'orders': 1, 'price': 972.6, 'quantity': 10},
{'orders': 2, 'price': 972.65, 'quantity': 27},
{'orders': 1, 'price': 972.7, 'quantity': 10}]},
'exchange_timestamp': datetime.datetime(2023, 1, 12, 13, 5, 4),
'instrument_token': 871681,
'last_price': 972.55,
'last_trade_time': datetime.datetime(2023, 1, 12, 13, 4, 53),
'last_traded_quantity': 1,
'mode': 'full',
'ohlc': {'close': 967.75, 'high': 978.6, 'low': 969.0, 'open': 971.75},
'oi': 0,
'oi_day_high': 0,
'oi_day_low': 0,
'total_buy_quantity': 152925,
'total_sell_quantity': 214765,
'tradable': True,
'volume_traded': 411290}]
Again, I will restate, THIS IS A BAD IDEA.
Read more on the specifics of eval here: https://realpython.com/python-eval-function/
Your JSON is not valid. You can check that by using an online JSON validator like this one: https://jsonformatter.org/
After entering the “JSON”, you can see it is not in a valid format.
You could either export it right, which I would highly recommend, or you could replace the wrong chars.
Currently, you have three issues:
You are using single quotes instead of double quotes
You are not parsing your datetime object, it looks like you just insert the object, you have to serialize it
You are writing true values as True, but that is the python way and not the JSON way. You either have to write it as true, or you have to pass it as a string. I would recommend the first one.
It could look like this (but I didnt parse datetime right, I just stringified it):
[{"tradable": true, "mode": "full", "instrument_token": 4708097, "last_price": 178.65, "last_traded_quantity": 5, "average_traded_price": 180.1, "volume_traded": 4581928, "total_buy_quantity": 1282853, "total_sell_quantity": 1673842, "ohlc": {"open": 181.95, "high": 181.95, "low": 177.8, "close": 181.0}, "change": -1.2983425414364609, "last_trade_time": "datetime.datetime(2023, 1, 12, 13, 4, 58)", "oi": 0, "oi_day_high": 0, "oi_day_low": 0, "exchange_timestamp": "datetime.datetime(2023, 1, 12, 13, 5, 1)", "depth": {"buy": [{"quantity": 653, "price": 178.6, "orders": 8}, {"quantity": 2408, "price": 178.55, "orders": 15}, {"quantity": 6329, "price": 178.5, "orders": 22}, {"quantity": 9161, "price": 178.45, "orders": 24}, {"quantity": 7775, "price": 178.4, "orders": 17}], "sell": [{"quantity": 5726, "price": 178.7, "orders": 8}, {"quantity": 4099, "price": 178.75, "orders": 11}, {"quantity": 23951, "price": 178.8, "orders": 25}, {"quantity": 7446, "price": 178.85, "orders": 21}, {"quantity": 11379, "price": 178.9, "orders": 21}]}}, {"tradable": true, "mode": "full", "instrument_token": 871681, "last_price": 972.55, "last_traded_quantity": 1, "average_traded_price": 973.85, "volume_traded": 411290, "total_buy_quantity": 152925, "total_sell_quantity": 214765, "ohlc": {"open": 971.75, "high": 978.6, "low": 969.0, "close": 967.75}, "change": 0.4959958667011061, "last_trade_time": "datetime.datetime(2023, 1, 12, 13, 4, 53)", "oi": 0, "oi_day_high": 0, "oi_day_low": 0, "exchange_timestamp": "datetime.datetime(2023, 1, 12, 13, 5, 4)", "depth": {"buy": [{"quantity": 6, "price": 972.15, "orders": 2}, {"quantity": 3, "price": 972.1, "orders": 2}, {"quantity": 15, "price": 972.05, "orders": 3}, {"quantity": 455, "price": 972.0, "orders": 16}, {"quantity": 14, "price": 971.95, "orders": 2}], "sell": [{"quantity": 6, "price": 972.5, "orders": 3}, {"quantity": 49, "price": 972.55, "orders": 2}, {"quantity": 10, "price": 972.6, "orders": 1}, {"quantity": 27, "price": 972.65, "orders": 2}, {"quantity": 10, "price": 972.7, "orders": 1}]}}]

Iterating over JSON data and printing. (or creating Pandas DataFrame from JSON file)

I’m trying to use Python print specific values from a JSON file that I pulled from an API. From what I understand, I am pulling it as a JSON file that has a list of dictionaries of players, with a nested dictionary for each player containing their data (i.e. name, team, etc.).
I’m running into issues printing the values within the JSON file, as each character is printing on a separate line.
The end result I am trying to get to is a Pandas DataFrame containing all the values from the JSON file, but I can’t even seem to iterate through the JSON file correctly.
Here is my code:
url = "https://api-football-v1.p.rapidapi.com/v3/players"
querystring = {"league":"39","season":"2020", "page":"2"}
headers = {
"X-RapidAPI-Host": "api-football-v1.p.rapidapi.com",
"X-RapidAPI-Key": "xxxxxkeyxxxxx"
}
response = requests.request("GET", url, headers=headers, params=querystring).json()
response_dump = json.dumps(response)
for item in response_dump:
for player_item in item:
print(player_item)
This is the output when I print the JSON response (first two items):
{'get': 'players', 'parameters': {'league': '39', 'page': '2', 'season': '2020'}, 'errors': [], 'results': 20, 'paging': {'current': 2, 'total': 37}, 'response': [{'player': {'id': 301, 'name': 'Benjamin Luke Woodburn', 'firstname': 'Benjamin Luke', 'lastname': 'Woodburn', 'age': 23, 'birth': {'date': '1999-10-15', 'place': 'Nottingham', 'country': 'England'}, 'nationality': 'Wales', 'height': '174 cm', 'weight': '72 kg', 'injured': False, 'photo': 'https://media.api-sports.io/football/players/301.png'}, 'statistics': [{'team': {'id': 40, 'name': 'Liverpool', 'logo': 'https://media.api-sports.io/football/teams/40.png'}, 'league': {'id': 39, 'name': 'Premier League', 'country': 'England', 'logo': 'https://media.api-sports.io/football/leagues/39.png', 'flag': 'https://media.api-sports.io/flags/gb.svg', 'season': 2020}, 'games': {'appearences': 0, 'lineups': 0, 'minutes': 0, 'number': None, 'position': 'Attacker', 'rating': None, 'captain': False}, 'substitutes': {'in': 0, 'out': 0, 'bench': 3}, 'shots': {'total': None, 'on': None}, 'goals': {'total': 0, 'conceded': 0, 'assists': None, 'saves': None}, 'passes': {'total': None, 'key': None, 'accuracy': None}, 'tackles': {'total': None, 'blocks': None, 'interceptions': None}, 'duels': {'total': None, 'won': None}, 'dribbles': {'attempts': None, 'success': None, 'past': None}, 'fouls': {'drawn': None, 'committed': None}, 'cards': {'yellow': 0, 'yellowred': 0, 'red': 0}, 'penalty': {'won': None, 'commited': None, 'scored': 0, 'missed': 0, 'saved': None}}]}, {'player': {'id': 518, 'name': 'Meritan Shabani', 'firstname': 'Meritan', 'lastname': 'Shabani', 'age': 23, 'birth': {'date': '1999-03-15', 'place': 'München', 'country': 'Germany'}, 'nationality': 'Germany', 'height': '185 cm', 'weight': '78 kg', 'injured': False, 'photo': 'https://media.api-sports.io/football/players/518.png'}, 'statistics': [{'team': {'id': 39, 'name': 'Wolves', 'logo': 'https://media.api-sports.io/football/teams/39.png'}, 'league': {'id': 39, 'name': 'Premier League', 'country': 'England', 'logo': 'https://media.api-sports.io/football/leagues/39.png', 'flag': 'https://media.api-sports.io/flags/gb.svg', 'season': 2020}, 'games': {'appearences': 0, 'lineups': 0, 'minutes': 0, 'number': None, 'position': 'Midfielder', 'rating': None, 'captain': False}, 'substitutes': {'in': 0, 'out': 0, 'bench': 3}, 'shots': {'total': None, 'on': None}, 'goals': {'total': 0, 'conceded': 0, 'assists': None, 'saves': None}, 'passes': {'total': None, 'key': None, 'accuracy': None}, 'tackles': {'total': None, 'blocks': None, 'interceptions': None}, 'duels': {'total': None, 'won': None}, 'dribbles': {'attempts': None, 'success': None, 'past': None}, 'fouls': {'drawn': None, 'committed': None}, 'cards': {'yellow': 0, 'yellowred': 0, 'red': 0}, 'penalty': {'won': None, 'commited': None, 'scored': 0, 'missed': 0, 'saved': None}}]},
This is the data type of each layer of the JSON file, from when I iterated through it with a For loop:
print(type(response)) <class 'dict'>
print(type(response_dump)) <class 'str'>
print(type(item)) <class 'str'>
print(type(player_item)) <class 'str'>
You do not have to json.dumps() in my opinion, just use the JSON from response to iterate:
for player in response['response']:
print(player)
{'player': {'id': 301, 'name': 'Benjamin Luke Woodburn', 'firstname': 'Benjamin Luke', 'lastname': 'Woodburn', 'age': 23, 'birth': {'date': '1999-10-15', 'place': 'Nottingham', 'country': 'England'}, 'nationality': 'Wales', 'height': '174 cm', 'weight': '72 kg', 'injured': False, 'photo': 'https://media.api-sports.io/football/players/301.png'}, 'statistics': [{'team': {'id': 40, 'name': 'Liverpool', 'logo': 'https://media.api-sports.io/football/teams/40.png'}, 'league': {'id': 39, 'name': 'Premier League', 'country': 'England', 'logo': 'https://media.api-sports.io/football/leagues/39.png', 'flag': 'https://media.api-sports.io/flags/gb.svg', 'season': 2020}, 'games': {'appearences': 0, 'lineups': 0, 'minutes': 0, 'number': None, 'position': 'Attacker', 'rating': None, 'captain': False}, 'substitutes': {'in': 0, 'out': 0, 'bench': 3}, 'shots': {'total': None, 'on': None}, 'goals': {'total': 0, 'conceded': 0, 'assists': None, 'saves': None}, 'passes': {'total': None, 'key': None, 'accuracy': None}, 'tackles': {'total': None, 'blocks': None, 'interceptions': None}, 'duels': {'total': None, 'won': None}, 'dribbles': {'attempts': None, 'success': None, 'past': None}, 'fouls': {'drawn': None, 'committed': None}, 'cards': {'yellow': 0, 'yellowred': 0, 'red': 0}, 'penalty': {'won': None, 'commited': None, 'scored': 0, 'missed': 0, 'saved': None}}]}
{'player': {'id': 518, 'name': 'Meritan Shabani', 'firstname': 'Meritan', 'lastname': 'Shabani', 'age': 23, 'birth': {'date': '1999-03-15', 'place': 'München', 'country': 'Germany'}, 'nationality': 'Germany', 'height': '185 cm', 'weight': '78 kg', 'injured': False, 'photo': 'https://media.api-sports.io/football/players/518.png'}, 'statistics': [{'team': {'id': 39, 'name': 'Wolves', 'logo': 'https://media.api-sports.io/football/teams/39.png'}, 'league': {'id': 39, 'name': 'Premier League', 'country': 'England', 'logo': 'https://media.api-sports.io/football/leagues/39.png', 'flag': 'https://media.api-sports.io/flags/gb.svg', 'season': 2020}, 'games': {'appearences': 0, 'lineups': 0, 'minutes': 0, 'number': None, 'position': 'Midfielder', 'rating': None, 'captain': False}, 'substitutes': {'in': 0, 'out': 0, 'bench': 3}, 'shots': {'total': None, 'on': None}, 'goals': {'total': 0, 'conceded': 0, 'assists': None, 'saves': None}, 'passes': {'total': None, 'key': None, 'accuracy': None}, 'tackles': {'total': None, 'blocks': None, 'interceptions': None}, 'duels': {'total': None, 'won': None}, 'dribbles': {'attempts': None, 'success': None, 'past': None}, 'fouls': {'drawn': None, 'committed': None}, 'cards': {'yellow': 0, 'yellowred': 0, 'red': 0}, 'penalty': {'won': None, 'commited': None, 'scored': 0, 'missed': 0, 'saved': None}}]}
or
for player in response['response']:
print(player['player'])
{'id': 301, 'name': 'Benjamin Luke Woodburn', 'firstname': 'Benjamin Luke', 'lastname': 'Woodburn', 'age': 23, 'birth': {'date': '1999-10-15', 'place': 'Nottingham', 'country': 'England'}, 'nationality': 'Wales', 'height': '174 cm', 'weight': '72 kg', 'injured': False, 'photo': 'https://media.api-sports.io/football/players/301.png'}
{'id': 518, 'name': 'Meritan Shabani', 'firstname': 'Meritan', 'lastname': 'Shabani', 'age': 23, 'birth': {'date': '1999-03-15', 'place': 'München', 'country': 'Germany'}, 'nationality': 'Germany', 'height': '185 cm', 'weight': '78 kg', 'injured': False, 'photo': 'https://media.api-sports.io/football/players/518.png'}
To get a DataFrame simply call pd.json_normalize() - Cause your question is not that clear I am not sure wiche information is needed and how to displayed. This is predestinated to ask a new question with exact that focus.:
pd.json_normalize(response['response'])
EDIT
Based on your comment and improvment:
pd.concat([pd.json_normalize(response,['response'])\
,pd.json_normalize(response,['response','statistics'])], axis=1)\
.drop(['statistics'], axis=1)
player.id
player.name
player.firstname
player.lastname
player.age
player.birth.date
player.birth.place
player.birth.country
player.nationality
player.height
player.weight
player.injured
player.photo
team.id
team.name
team.logo
league.id
league.name
league.country
league.logo
league.flag
league.season
games.appearences
games.lineups
games.minutes
games.number
games.position
games.rating
games.captain
substitutes.in
substitutes.out
substitutes.bench
shots.total
shots.on
goals.total
goals.conceded
goals.assists
goals.saves
passes.total
passes.key
passes.accuracy
tackles.total
tackles.blocks
tackles.interceptions
duels.total
duels.won
dribbles.attempts
dribbles.success
dribbles.past
fouls.drawn
fouls.committed
cards.yellow
cards.yellowred
cards.red
penalty.won
penalty.commited
penalty.scored
penalty.missed
penalty.saved
0
301
Benjamin Luke Woodburn
Benjamin Luke
Woodburn
23
1999-10-15
Nottingham
England
Wales
174 cm
72 kg
False
https://media.api-sports.io/football/players/301.png
40
Liverpool
https://media.api-sports.io/football/teams/40.png
39
Premier League
England
https://media.api-sports.io/football/leagues/39.png
https://media.api-sports.io/flags/gb.svg
2020
0
0
0
Attacker
False
0
0
3
0
0
0
0
0
0
0
1
518
Meritan Shabani
Meritan
Shabani
23
1999-03-15
München
Germany
Germany
185 cm
78 kg
False
https://media.api-sports.io/football/players/518.png
39
Wolves
https://media.api-sports.io/football/teams/39.png
39
Premier League
England
https://media.api-sports.io/football/leagues/39.png
https://media.api-sports.io/flags/gb.svg
2020
0
0
0
Midfielder
False
0
0
3
0
0
0
0
0
0
0

How to do error-handling of JSON Parser Loop

I found some elegant code that builds a list by iterating through each element of another JSON list:
results = [
(
t["vintage"]["wine"]["winery"]["name"],
t["vintage"]["year"],
t["vintage"]["wine"]["id"],
f'{t["vintage"]["wine"]["name"]} {t["vintage"]["year"]}',
t["vintage"]["wine"]["statistics"]["ratings_average"],
t["vintage"]["wine"]["statistics"]["ratings_count"],
t["price"]["amount"],
t["vintage"]["wine"]["region"]["name"],
t["vintage"]["wine"]["style"]["name"], #<--------------issue here
)
for t in r.json()["explore_vintage"]["matches"]
]
The problem is that sometimes the JSON doesn't have a "name" element because the "style" is null (or None in JSON world). See the second-last line below for the JSON sample.
Is there a simple way to handle this error?
Error:
matches[23]["vintage"]["wine"]["style"]["name"]
Traceback (most recent call last):
File "<ipython-input-94-59447d0d4859>", line 1, in <module>
matches[23]["vintage"]["wine"]["style"]["name"]
TypeError: 'NoneType' object is not subscriptable
Perhaps something like:
iferror(t["vintage"]["wine"]["style"]["name"], "DoesNotExist")
JSON:
{'id': 4026076,
'name': 'Shiraz - Petit Verdot',
'seo_name': 'shiraz-petit-verdot',
'type_id': 1,
'vintage_type': 0,
'is_natural': False,
'region': {'id': 685,
'name': 'South Eastern Australia',
'name_en': '',
'seo_name': 'south-eastern',
'country': {'code': 'au',
'name': 'Australia',
'native_name': 'Australia',
'seo_name': 'australia',
'sponsored': False,
'currency': {'code': 'AUD',
'name': 'Australian Dollars',
'prefix': '$',
'suffix': None},
'regions_count': 120,
'users_count': 867353,
'wines_count': 108099,
'wineries_count': 13375,
'most_used_grapes': [{'id': 1,
'name': 'Shiraz/Syrah',
'seo_name': 'shiraz-syrah',
'has_detailed_info': True,
'wines_count': 536370},
{'id': 2,
'name': 'Cabernet Sauvignon',
'seo_name': 'cabernet-sauvignon',
'has_detailed_info': True,
'wines_count': 780931},
{'id': 5,
'name': 'Chardonnay',
'seo_name': 'chardonnay',
'has_detailed_info': True,
'wines_count': 586874}],
'background_video': None},
'class': {'typecast_map': {'background_image': {}, 'class': {}}},
'background_image': {'location': '//images.vivino.com/regions/backgrounds/0iT8wuQXRWaAmEGpPjZckg.jpg',
'variations': {'large': '//thumbs.vivino.com/region_backgrounds/0iT8wuQXRWaAmEGpPjZckg_1280x760.jpg',
'medium': '//thumbs.vivino.com/region_backgrounds/0iT8wuQXRWaAmEGpPjZckg_600x356.jpg'}}},
'winery': {'id': 74363,
'name': 'Barramundi',
'seo_name': 'barramundi',
'status': 0,
'background_image': None},
'taste': {'structure': None,
'flavor': [{'group': 'black_fruit', 'stats': {'count': 16, 'score': 2987}},
{'group': 'oak', 'stats': {'count': 11, 'score': 1329}},
{'group': 'red_fruit', 'stats': {'count': 10, 'score': 1413}},
{'group': 'spices', 'stats': {'count': 6, 'score': 430}},
{'group': 'non_oak', 'stats': {'count': 5, 'score': 126}},
{'group': 'floral', 'stats': {'count': 3, 'score': 300}},
{'group': 'earth', 'stats': {'count': 3, 'score': 249}},
{'group': 'microbio', 'stats': {'count': 2, 'score': 66}},
{'group': 'vegetal', 'stats': {'count': 1, 'score': 100}},
{'group': 'dried_fruit', 'stats': {'count': 1, 'score': 100}}]},
'statistics': {'status': 'Normal',
'ratings_count': 1002,
'ratings_average': 3.5,
'labels_count': 11180,
'vintages_count': 25},
'style': None,
'has_valid_ratings': True}

Is one of the numbers in this list in between the two given integers?

I have a list with barline ticks and midi notes that can overlap the barlines. So I made a list of 'barlineticks':
barlinepos = [0, 768.0, 1536.0, 2304.0, 3072.0, 3840.0, 4608.0, 5376.0, 6144.0, 6912.0, 0, 576.0, 1152.0, 1728.0, 2304.0, 2880.0, 3456.0, 4032.0, 4608.0, 5184.0, 5760.0, 6336.0, 6912.0, 7488.0]
And a MidiFile:
{'type': 'time_signature', 'numerator': 4, 'denominator': 4, 'time': 0, 'duration': 768, 'ID': 0}
{'type': 'set_tempo', 'tempo': 500000, 'time': 0, 'ID': 1}
{'type': 'track_name', 'name': 'Tempo Track', 'time': 0, 'ID': 2}
{'type': 'track_name', 'name': 'New Instrument', 'time': 0, 'ID': 3}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 48, 'velocity': 100, 'ID': 4, 'duration': 956}
{'type': 'time_signature', 'numerator': 3, 'denominator': 4, 'time': 768, 'duration': 6911, 'ID': 5}
{'type': 'note_on', 'time': 768, 'channel': 0, 'note': 46, 'velocity': 100, 'ID': 6, 'duration': 575}
{'type': 'note_off', 'time': 956, 'channel': 0, 'note': 48, 'velocity': 0, 'ID': 7}
{'type': 'note_off', 'time': 1343, 'channel': 0, 'note': 46, 'velocity': 0, 'ID': 8}
{'type': 'end_of_track', 'time': 7679, 'ID': 9}
And I want to check if the midi note is overlapping a barline. Every note_on message has a 'time' and a 'duration' value. I have to check if one of the barlineticks(in the list) is inside the range of the note('time' and 'duration'). I tried:
if barlinepos in range(0, 956):
print(True)
Of course this doesn't work because barlinepos is a list. How can I check if one of the values in the list results in True?
Simple iteration to solve the requirement:
for i in midifile:
start, end = i["time"], i["time"]+i["duration"]
for j in barlinepos:
if j >= start and j<= end:
print(True)
break
print(False)

How I take my modified JSON list and export it to CSV?

I wrote a Python script. It has an untrusted variable with this in it:
[{'id': 42042052, 'name': 'Lyft', 'package': 'com.abtutorial10.canadalyft5', 'uname': 'com-abtutorial10-canadalyft5', 'size': 2342327, 'icon': 'http://pool.img.xxxxxxx.com/appsdally/85767fc7ff03601ce1325fdedd9cf0dd_icon.png', 'graphic': 'http://pool.img.xxxxxxx.com/appsdally/f0687693ea3eb5116894509683fa3f9d_fgraphic_705x345.jpg', 'added': '2018-11-23 15:23:47', 'modified': '2018-11-23 15:23:47', 'updated': '2018-11-23 15:23:47', 'uptype': 'regular', 'store': {'id': 2327139, 'name': 'appsdally', 'avatar': 'http://pool.img.xxxxxxx.com/appsdally/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 66, 'subscribers': 4, 'downloads': 4472}}, 'file': {'vername': '2.1', 'vercode': 2, 'md5sum': '06ae32afa8d57b9a3fc19f24e658898f', 'filesize': 2342327, 'path': 'http://pool.apk.xxxxxxx.com/appsdally/com-abtutorial10-canadalyft5-2-42042052-06ae32afa8d57b9a3fc19f24e658898f.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/appsdally/alt/Y29tLWFidHV0b3JpYWwxMC1jYW5hZGFseWZ0NS0yLTQyMDQyMDUyLTA2YWUzMmFmYThkNTdiOWEzZmMxOWYyNGU2NTg4OThm.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 7, 'pdownloads': 15, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 42033673, 'name': 'Lyft', 'package': 'com.abtutorial10.canadalyft4', 'uname': 'com-abtutorial10-canadalyft4', 'size': 2342311, 'icon': 'http://pool.img.xxxxxxx.com/apps0007/85767fc7ff03601ce1325fdedd9cf0dd_icon.png', 'graphic': 'http://pool.img.xxxxxxx.com/apps0007/f0687693ea3eb5116894509683fa3f9d_fgraphic_705x345.jpg', 'added': '2018-11-23 05:42:04', 'modified': '2018-11-23 05:42:05', 'updated': '2018-11-23 05:42:05', 'uptype': 'regular', 'store': {'id': 2273010, 'name': 'apps0007', 'avatar': 'http://pool.img.xxxxxxx.com/apps0007/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'pink', 'description': ''}, 'stats': {'apps': 218, 'subscribers': 65, 'downloads': 71922}}, 'file': {'vername': '2.1', 'vercode': 2, 'md5sum': '5a26e3c55946ba221b0dd041fee927f8', 'filesize': 2342311, 'path': 'http://pool.apk.xxxxxxx.com/apps0007/com-abtutorial10-canadalyft4-2-42033673-5a26e3c55946ba221b0dd041fee927f8.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/apps0007/alt/Y29tLWFidHV0b3JpYWwxMC1jYW5hZGFseWZ0NC0yLTQyMDMzNjczLTVhMjZlM2M1NTk0NmJhMjIxYjBkZDA0MWZlZTkyN2Y4.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 46, 'pdownloads': 46, 'rating': {'avg': 5, 'total': 1}, 'prating': {'avg': 5, 'total': 1}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 41878039, 'name': 'Lyft', 'package': 'com.abtutorial10.canadalyft', 'uname': 'com-abtutorial10-canadalyft', 'size': 2342303, 'icon': 'http://pool.img.xxxxxxx.com/appsstoremarket/85767fc7ff03601ce1325fdedd9cf0dd_icon.png', 'graphic': 'http://pool.img.xxxxxxx.com/appsstoremarket/f0687693ea3eb5116894509683fa3f9d_fgraphic_705x345.jpg', 'added': '2018-11-16 06:58:24', 'modified': '2018-11-16 06:58:24', 'updated': '2018-11-16 06:58:24', 'uptype': 'regular', 'store': {'id': 2122330, 'name': 'appsstoremarket', 'avatar': 'http://pool.img.xxxxxxx.com/appsstoremarket/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 345, 'subscribers': 162, 'downloads': 156669}}, 'file': {'vername': '2.1', 'vercode': 2, 'md5sum': 'ad47c17dc87d9f50d0cebd4fc71c3542', 'filesize': 2342303, 'path': 'http://pool.apk.xxxxxxx.com/appsstoremarket/com-abtutorial10-canadalyft-2-41878039-ad47c17dc87d9f50d0cebd4fc71c3542.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/appsstoremarket/alt/Y29tLWFidHV0b3JpYWwxMC1jYW5hZGFseWZ0LTItNDE4NzgwMzktYWQ0N2MxN2RjODdkOWY1MGQwY2ViZDRmYzcxYzM1NDI.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 27, 'pdownloads': 27, 'rating': {'avg': 5, 'total': 1}, 'prating': {'avg': 5, 'total': 1}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 41989617, 'name': 'Lyft', 'package': 'com.abtutorial10.canadalyft2', 'uname': 'com-abtutorial10-canadalyft2', 'size': 2342287, 'icon': 'http://pool.img.xxxxxxx.com/apps018/85767fc7ff03601ce1325fdedd9cf0dd_icon.png', 'graphic': 'http://pool.img.xxxxxxx.com/apps018/f0687693ea3eb5116894509683fa3f9d_fgraphic_705x345.jpg', 'added': '2018-11-21 08:04:06', 'modified': '2018-11-21 08:04:07', 'updated': '2018-11-21 08:04:07', 'uptype': 'regular', 'store': {'id': 2273237, 'name': 'apps018', 'avatar': 'http://pool.img.xxxxxxx.com/apps018/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 176, 'subscribers': 38, 'downloads': 23996}}, 'file': {'vername': '2.1', 'vercode': 2, 'md5sum': '0b4c234a748a6c42bb6c86f56787cf10', 'filesize': 2342287, 'path': 'http://pool.apk.xxxxxxx.com/apps018/com-abtutorial10-canadalyft2-2-41989617-0b4c234a748a6c42bb6c86f56787cf10.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/apps018/alt/Y29tLWFidHV0b3JpYWwxMC1jYW5hZGFseWZ0Mi0yLTQxOTg5NjE3LTBiNGMyMzRhNzQ4YTZjNDJiYjZjODZmNTY3ODdjZjEw.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 8, 'pdownloads': 8, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 41879202, 'name': 'Lyft', 'package': 'com.abtutorial10.canadalyft8', 'uname': 'com-abtutorial10-canadalyft8', 'size': 2342339, 'icon': 'http://pool.img.xxxxxxx.com/originalyes/85767fc7ff03601ce1325fdedd9cf0dd_icon.png', 'graphic': 'http://pool.img.xxxxxxx.com/originalyes/c83abedbcad184c9f8ce6856dd63274e_fgraphic_705x345.jpg', 'added': '2018-11-16 08:37:55', 'modified': '2018-11-16 08:37:56', 'updated': '2018-11-16 08:37:56', 'uptype': 'regular', 'store': {'id': 2268473, 'name': 'originalyes', 'avatar': 'http://pool.img.xxxxxxx.com/originalyes/da3bd21b288e5f980cc44ff6953fd9e5_ravatar.png', 'appearance': {'theme': 'pink', 'description': ''}, 'stats': {'apps': 151, 'subscribers': 33, 'downloads': 25408}}, 'file': {'vername': '2.1', 'vercode': 2, 'md5sum': 'd8c749ad0e7523c7887b029d52bc0411', 'filesize': 2342339, 'path': 'http://pool.apk.xxxxxxx.com/originalyes/com-abtutorial10-canadalyft8-2-41879202-d8c749ad0e7523c7887b029d52bc0411.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/originalyes/alt/Y29tLWFidHV0b3JpYWwxMC1jYW5hZGFseWZ0OC0yLTQxODc5MjAyLWQ4Yzc0OWFkMGU3NTIzYzc4ODdiMDI5ZDUyYmMwNDEx.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 7, 'pdownloads': 7, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 31174138, 'name': 'Surge Chaser for Lyft', 'package': 'com.uplyftprime', 'uname': 'surge-chaser-for-lyft', 'size': 9885571, 'icon': 'http://pool.img.xxxxxxx.com/devlindelfuego/6ae78524c53ca97c15c9b2befe58a3cc_icon.png', 'graphic': None, 'added': '2017-08-06 08:23:23', 'modified': '2017-08-06 08:23:24', 'updated': '2017-08-06 08:23:24', 'uptype': 'aptbackup', 'store': {'id': 1618717, 'name': 'devlindelfuego', 'avatar': 'http://pool.img.xxxxxxx.com/devlindelfuego/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 164, 'subscribers': 12, 'downloads': 3328}}, 'file': {'vername': '1.029', 'vercode': 30, 'md5sum': 'cc202eb8de4569095aec2f86b7265f94', 'filesize': 9885571, 'path': 'http://pool.apk.xxxxxxx.com/devlindelfuego/com-uplyftprime-30-31174138-cc202eb8de4569095aec2f86b7265f94.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/devlindelfuego/alt/Y29tLXVwbHlmdHByaW1lLTMwLTMxMTc0MTM4LWNjMjAyZWI4ZGU0NTY5MDk1YWVjMmY4NmI3MjY1Zjk0.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 10, 'pdownloads': 11, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': True, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 26296353, 'name': 'Lyft car hire', 'package': 'cc.snapp.app_lyft_car_hire', 'uname': 'lyft-car-hire', 'size': 49270686, 'icon': 'http://pool.img.xxxxxxx.com/snappbuilder/1a3e8d7ee63aee4ce41f4f09afc5eb6e.png', 'graphic': None, 'added': '2017-04-23 08:45:23', 'modified': '2017-04-23 08:45:23', 'updated': '2017-04-23 08:45:23', 'uptype': 'webservice', 'store': {'id': 992935, 'name': 'snappbuilder', 'avatar': 'http://pool.img.xxxxxxx.com/snappbuilder/4fd67e18c3369c00e55d58854466d4fb_ravatar.png', 'appearance': {'theme': 'lightsky', 'description': ''}, 'stats': {'apps': 11364, 'subscribers': 4879, 'downloads': 655515}}, 'file': {'vername': '1.9.2', 'vercode': 570313178, 'md5sum': 'a7475d8c27b7672f1020013847a8ea6e', 'filesize': 49270686, 'path': 'http://pool.apk.xxxxxxx.com/snappbuilder/cc-snapp-app-lyft-car-hire-570313178-26296353-a7475d8c27b7672f1020013847a8ea6e.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/snappbuilder/alt/Y2Mtc25hcHAtYXBwLWx5ZnQtY2FyLWhpcmUtNTcwMzEzMTc4LTI2Mjk2MzUzLWE3NDc1ZDhjMjdiNzY3MmYxMDIwMDEzODQ3YThlYTZl.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 2, 'pdownloads': 3, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 23145792, 'name': 'Assist4Lyft: Lyft Promo Codes', 'package': 'com.thelyftrider.lyftassist', 'uname': 'assist-4lyft', 'size': 5850532, 'icon': 'http://pool.img.xxxxxxx.com/vegasrome/199e862cf067a80d5ef93617ac7f14c8_icon.png', 'graphic': None, 'added': '2017-01-28 11:53:43', 'modified': '2017-01-28 11:53:43', 'updated': '2018-02-06 01:12:25', 'uptype': 'aptuploader', 'store': {'id': 52879, 'name': 'vegasrome', 'avatar': 'http://pool.img.xxxxxxx.com/vegasrome/3c9c3ea9ed74341c8a45890d6ea32fb3_ravatar.png', 'appearance': {'theme': 'black', 'description': 'Enjoy and keep in mind.. some of my uploads my require Lucky Patcher, Google Play Mod, and ROOT\r\nDo my best to bring you latest versions.'}, 'stats': {'apps': 8856, 'subscribers': 19216, 'downloads': 3672234}}, 'file': {'vername': '1.0', 'vercode': 1, 'md5sum': '817c42f6a997ef8bc60e54c61bbcfb71', 'filesize': 5850532, 'path': 'http://pool.apk.xxxxxxx.com/vegasrome/com-thelyftrider-lyftassist-1-23145792-817c42f6a997ef8bc60e54c61bbcfb71.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/vegasrome/alt/Y29tLXRoZWx5ZnRyaWRlci1seWZ0YXNzaXN0LTEtMjMxNDU3OTItODE3YzQyZjZhOTk3ZWY4YmM2MGU1NGM2MWJiY2ZiNzE.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 29, 'pdownloads': 30, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 21730958, 'name': 'FareWell', 'package': 'com.farewell', 'uname': 'robert-niimi-farewell', 'size': 8932627, 'icon': 'http://pool.img.xxxxxxx.com/yupofcourse/31d67d608e150feb9ab632c9be86d482_icon.png', 'graphic': None, 'added': '2016-11-08 04:49:30', 'modified': '2016-11-08 04:49:31', 'updated': '2017-01-28 11:50:44', 'uptype': 'aptbackup', 'store': {'id': 1077022, 'name': 'yupofcourse', 'avatar': 'http://pool.img.xxxxxxx.com/yupofcourse/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'pink', 'description': ''}, 'stats': {'apps': 2677, 'subscribers': 1792, 'downloads': 371478}}, 'file': {'vername': '1.0', 'vercode': 1, 'md5sum': 'e61d398585197b8ed0df2a08f79396b8', 'filesize': 8932627, 'path': 'http://pool.apk.xxxxxxx.com/yupofcourse/com-farewell-1-21730958-e61d398585197b8ed0df2a08f79396b8.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/yupofcourse/alt/Y29tLWZhcmV3ZWxsLTEtMjE3MzA5NTgtZTYxZDM5ODU4NTE5N2I4ZWQwZGYyYTA4Zjc5Mzk2Yjg.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 30, 'pdownloads': 30, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 39440400, 'name': 'Free Taxi Coupons For Lyft', 'package': 'com.pulsarappz.freetaxicouponsforlyft', 'uname': 'free-taxi-coupons-for-lyft', 'size': 5898638, 'icon': 'http://pool.img.xxxxxxx.com/lm2442/e919b13803869a85bfc01a44bea9f854_icon.png', 'graphic': None, 'added': '2018-08-09 05:58:07', 'modified': '2018-08-09 05:58:07', 'updated': '2018-08-09 05:58:07', 'uptype': 'aptuploader', 'store': {'id': 2173406, 'name': 'lm2442', 'avatar': 'http://pool.img.xxxxxxx.com/lm2442/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'black', 'description': 'Browns'}, 'stats': {'apps': 43, 'subscribers': 1, 'downloads': 68}}, 'file': {'vername': '1.9', 'vercode': 10, 'md5sum': 'a50e0aea81b50407bed88d1a46a8afed', 'filesize': 5898638, 'path': 'http://pool.apk.xxxxxxx.com/lm2442/com-pulsarappz-freetaxicouponsforlyft-10-39440400-a50e0aea81b50407bed88d1a46a8afed.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/lm2442/alt/Y29tLXB1bHNhcmFwcHotZnJlZXRheGljb3Vwb25zZm9ybHlmdC0xMC0zOTQ0MDQwMC1hNTBlMGFlYTgxYjUwNDA3YmVkODhkMWE0NmE4YWZlZA.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 8, 'pdownloads': 10, 'rating': {'avg': 5, 'total': 1}, 'prating': {'avg': 5, 'total': 1}}, 'has_versions': True, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 18107829, 'name': 'Lyft Taxi Bus Alternative', 'package': 'net.krwkfy.lyft.taxi.bus.alternative', 'uname': 'krwkfy-lyft-taxi-alternative', 'size': 4205039, 'icon': 'http://pool.img.xxxxxxx.com/helenayzes/3d153d49aa7ddd882f95318bed089ad6.png', 'graphic': None, 'added': '2016-03-10 02:13:22', 'modified': '2016-03-10 02:13:22', 'updated': '2016-03-10 02:13:22', 'uptype': 'webservice', 'store': {'id': 949999, 'name': 'helenayzes', 'avatar': 'http://pool.img.xxxxxxx.com/helenayzes/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 21, 'subscribers': 5, 'downloads': 2182}}, 'file': {'vername': '8.1.1008', 'vercode': 392145239, 'md5sum': '9ca5a51a6e7ba88465676201c25d1291', 'filesize': 4205039, 'path': 'http://pool.apk.xxxxxxx.com/helenayzes/net-krwkfy-lyft-taxi-bus-alternative-392145239-18107829-9ca5a51a6e7ba88465676201c25d1291.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/helenayzes/alt/bmV0LWtyd2tmeS1seWZ0LXRheGktYnVzLWFsdGVybmF0aXZlLTM5MjE0NTIzOS0xODEwNzgyOS05Y2E1YTUxYTZlN2JhODg0NjU2NzYyMDFjMjVkMTI5MQ.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 13, 'pdownloads': 13, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 23075890, 'name': 'Fare Compare Uber, Lyft & Taxi', 'package': 'com.zailoo.xroads', 'uname': 'goa2b', 'size': 8712680, 'icon': 'http://pool.img.xxxxxxx.com/moshkosh/afd317768d4e241c2f6b86dea7810464_icon.png', 'graphic': None, 'added': '2017-01-21 09:30:00', 'modified': '2017-01-21 09:30:01', 'updated': '2017-04-18 04:00:55', 'uptype': 'aptbackup', 'store': {'id': 1128043, 'name': 'moshkosh', 'avatar': 'http://pool.img.xxxxxxx.com/moshkosh/31d3c02ce8ddbeaa844ba1b0aa1d6cb2_ravatar.jpg', 'appearance': {'theme': 'light-blue', 'description': "Everything you want, Nothing you need.. \nOn a real note though, I upload the apps I frequent as well as the one timers I don't."}, 'stats': {'apps': 2333, 'subscribers': 165, 'downloads': 52338}}, 'file': {'vername': '2.1.0', 'vercode': 10148, 'md5sum': 'fc91fbde809abb73e259563820aa2593', 'filesize': 8712680, 'path': 'http://pool.apk.xxxxxxx.com/moshkosh/com-zailoo-xroads-10148-23075890-fc91fbde809abb73e259563820aa2593.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/moshkosh/alt/Y29tLXphaWxvby14cm9hZHMtMTAxNDgtMjMwNzU4OTAtZmM5MWZiZGU4MDlhYmI3M2UyNTk1NjM4MjBhYTI1OTM.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 8, 'pdownloads': 10, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': True, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 5971395, 'name': 'lyft uber easy taxi cabs', 'package': 'thetaxiapp.com', 'uname': 'lyft-uber-easy-taxi-cabs', 'size': 3442701, 'icon': 'http://pool.img.xxxxxxx.com/shaddon-green/ecb0e8b1ce78b612c06288cb194d6818_icon.png', 'graphic': None, 'added': '2014-06-04 06:38:56', 'modified': '2014-06-04 06:38:56', 'updated': '2014-06-04 06:38:56', 'uptype': 'aptbackup', 'store': {'id': 120645, 'name': 'shaddon-green', 'avatar': 'http://pool.img.xxxxxxx.com/shaddon-green/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'indigo', 'description': ''}, 'stats': {'apps': 1255, 'subscribers': 697, 'downloads': 115051}}, 'file': {'vername': '6.1.0.0.14', 'vercode': 177, 'md5sum': 'edddd6358e0c60b15caef4322341d3ff', 'filesize': 3442701, 'path': 'http://pool.apk.xxxxxxx.com/shaddon-green/thetaxiapp-com-177-5971395-edddd6358e0c60b15caef4322341d3ff.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/shaddon-green/alt/dGhldGF4aWFwcC1jb20tMTc3LTU5NzEzOTUtZWRkZGQ2MzU4ZTBjNjBiMTVjYWVmNDMyMjM0MWQzZmY.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 303, 'pdownloads': 294, 'rating': {'avg': 5, 'total': 2}, 'prating': {'avg': 5, 'total': 2}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 37966226, 'name': 'Free Taxi Ride Coupons for Lyft', 'package': 'com.appfactory.taxicouponslyft', 'uname': 'taxi-coupons-lyft', 'size': 4902371, 'icon': 'http://pool.img.xxxxxxx.com/vivo-api/699da34f6b1cede35beda1f20ffa600d_icon.png', 'graphic': None, 'added': '2018-06-08 02:22:53', 'modified': '2018-06-08 02:22:53', 'updated': '2018-06-08 02:22:53', 'uptype': 'webservice', 'store': {'id': 1463246, 'name': 'vivo-api', 'avatar': 'http://pool.img.xxxxxxx.com/vivo-api/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 123417, 'subscribers': 6878, 'downloads': 4220618}}, 'file': {'vername': '1.2', 'vercode': 3, 'md5sum': 'a7fcb7844b897b95d2f8fd9dae6d716d', 'filesize': 4902371, 'path': 'http://pool.apk.xxxxxxx.com/vivo-api/com-appfactory-taxicouponslyft-3-37966226-a7fcb7844b897b95d2f8fd9dae6d716d.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/vivo-api/alt/Y29tLWFwcGZhY3RvcnktdGF4aWNvdXBvbnNseWZ0LTMtMzc5NjYyMjYtYTdmY2I3ODQ0Yjg5N2I5NWQyZjhmZDlkYWU2ZDcxNmQ.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 8, 'pdownloads': 8, 'rating': {'avg': 5, 'total': 1}, 'prating': {'avg': 5, 'total': 1}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 38283734, 'name': 'Free Ride Promos for Lyft Cab', 'package': 'com.shineappzz.newlyftcoupons', 'uname': 'newlyftcoupons-big-shine-team', 'size': 4217943, 'icon': 'http://pool.img.xxxxxxx.com/legacyapps13/1d630b774f661acaace44e9f54f43f71_icon.png', 'graphic': None, 'added': '2018-06-20 16:23:24', 'modified': '2018-06-20 16:23:24', 'updated': '2018-06-20 16:23:24', 'uptype': 'aptuploader', 'store': {'id': 2025398, 'name': 'legacyapps13', 'avatar': 'http://pool.img.xxxxxxx.com/legacyapps13/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 84, 'subscribers': 44, 'downloads': 19482}}, 'file': {'vername': '1.0', 'vercode': 1, 'md5sum': 'b6df2843e8025eac0b10853f1af3fcb6', 'filesize': 4217943, 'path': 'http://pool.apk.xxxxxxx.com/legacyapps13/com-shineappzz-newlyftcoupons-1-38283734-b6df2843e8025eac0b10853f1af3fcb6.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/legacyapps13/alt/Y29tLXNoaW5lYXBwenotbmV3bHlmdGNvdXBvbnMtMS0zODI4MzczNC1iNmRmMjg0M2U4MDI1ZWFjMGIxMDg1M2YxYWYzZmNiNg.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 3, 'pdownloads': 3, 'rating': {'avg': 5, 'total': 1}, 'prating': {'avg': 5, 'total': 1}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 39440422, 'name': 'Taxi Coupons for Lyft - Canada & USA', 'package': 'com.pulsarappz.couponsforlyft_usandcanada', 'uname': 'coupons-for-lyft-us-and-canada', 'size': 6186897, 'icon': 'http://pool.img.xxxxxxx.com/lm2442/f561c396db660e6989ea894953166976_icon.png', 'graphic': None, 'added': '2018-08-09 05:59:09', 'modified': '2018-08-09 05:59:10', 'updated': '2018-08-09 05:59:10', 'uptype': 'aptuploader', 'store': {'id': 2173406, 'name': 'lm2442', 'avatar': 'http://pool.img.xxxxxxx.com/lm2442/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'black', 'description': 'Browns'}, 'stats': {'apps': 43, 'subscribers': 1, 'downloads': 68}}, 'file': {'vername': '5.0', 'vercode': 5, 'md5sum': 'afc9cb352de940d11b5e0a1437261d4c', 'filesize': 6186897, 'path': 'http://pool.apk.xxxxxxx.com/lm2442/com-pulsarappz-couponsforlyft-usandcanada-5-39440422-afc9cb352de940d11b5e0a1437261d4c.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/lm2442/alt/Y29tLXB1bHNhcmFwcHotY291cG9uc2Zvcmx5ZnQtdXNhbmRjYW5hZGEtNS0zOTQ0MDQyMi1hZmM5Y2IzNTJkZTk0MGQxMWI1ZTBhMTQzNzI2MWQ0Yw.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 2, 'pdownloads': 2, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}]
How do I take untrusted and export it to my CSV file, new_csv, in the proper CSV format?
If you're just looking to convert that to dataframe, you can use json_normalize. Then take that dataframe and save as csv.
data = [{'id': 42042052, 'name': 'Lyft', 'package': 'com.abtutorial10.canadalyft5', 'uname': 'com-abtutorial10-canadalyft5', 'size': 2342327, 'icon': 'http://pool.img.xxxxxxx.com/appsdally/85767fc7ff03601ce1325fdedd9cf0dd_icon.png', 'graphic': 'http://pool.img.xxxxxxx.com/appsdally/f0687693ea3eb5116894509683fa3f9d_fgraphic_705x345.jpg', 'added': '2018-11-23 15:23:47', 'modified': '2018-11-23 15:23:47', 'updated': '2018-11-23 15:23:47', 'uptype': 'regular', 'store': {'id': 2327139, 'name': 'appsdally', 'avatar': 'http://pool.img.xxxxxxx.com/appsdally/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 66, 'subscribers': 4, 'downloads': 4472}}, 'file': {'vername': '2.1', 'vercode': 2, 'md5sum': '06ae32afa8d57b9a3fc19f24e658898f', 'filesize': 2342327, 'path': 'http://pool.apk.xxxxxxx.com/appsdally/com-abtutorial10-canadalyft5-2-42042052-06ae32afa8d57b9a3fc19f24e658898f.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/appsdally/alt/Y29tLWFidHV0b3JpYWwxMC1jYW5hZGFseWZ0NS0yLTQyMDQyMDUyLTA2YWUzMmFmYThkNTdiOWEzZmMxOWYyNGU2NTg4OThm.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 7, 'pdownloads': 15, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 42033673, 'name': 'Lyft', 'package': 'com.abtutorial10.canadalyft4', 'uname': 'com-abtutorial10-canadalyft4', 'size': 2342311, 'icon': 'http://pool.img.xxxxxxx.com/apps0007/85767fc7ff03601ce1325fdedd9cf0dd_icon.png', 'graphic': 'http://pool.img.xxxxxxx.com/apps0007/f0687693ea3eb5116894509683fa3f9d_fgraphic_705x345.jpg', 'added': '2018-11-23 05:42:04', 'modified': '2018-11-23 05:42:05', 'updated': '2018-11-23 05:42:05', 'uptype': 'regular', 'store': {'id': 2273010, 'name': 'apps0007', 'avatar': 'http://pool.img.xxxxxxx.com/apps0007/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'pink', 'description': ''}, 'stats': {'apps': 218, 'subscribers': 65, 'downloads': 71922}}, 'file': {'vername': '2.1', 'vercode': 2, 'md5sum': '5a26e3c55946ba221b0dd041fee927f8', 'filesize': 2342311, 'path': 'http://pool.apk.xxxxxxx.com/apps0007/com-abtutorial10-canadalyft4-2-42033673-5a26e3c55946ba221b0dd041fee927f8.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/apps0007/alt/Y29tLWFidHV0b3JpYWwxMC1jYW5hZGFseWZ0NC0yLTQyMDMzNjczLTVhMjZlM2M1NTk0NmJhMjIxYjBkZDA0MWZlZTkyN2Y4.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 46, 'pdownloads': 46, 'rating': {'avg': 5, 'total': 1}, 'prating': {'avg': 5, 'total': 1}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 41878039, 'name': 'Lyft', 'package': 'com.abtutorial10.canadalyft', 'uname': 'com-abtutorial10-canadalyft', 'size': 2342303, 'icon': 'http://pool.img.xxxxxxx.com/appsstoremarket/85767fc7ff03601ce1325fdedd9cf0dd_icon.png', 'graphic': 'http://pool.img.xxxxxxx.com/appsstoremarket/f0687693ea3eb5116894509683fa3f9d_fgraphic_705x345.jpg', 'added': '2018-11-16 06:58:24', 'modified': '2018-11-16 06:58:24', 'updated': '2018-11-16 06:58:24', 'uptype': 'regular', 'store': {'id': 2122330, 'name': 'appsstoremarket', 'avatar': 'http://pool.img.xxxxxxx.com/appsstoremarket/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 345, 'subscribers': 162, 'downloads': 156669}}, 'file': {'vername': '2.1', 'vercode': 2, 'md5sum': 'ad47c17dc87d9f50d0cebd4fc71c3542', 'filesize': 2342303, 'path': 'http://pool.apk.xxxxxxx.com/appsstoremarket/com-abtutorial10-canadalyft-2-41878039-ad47c17dc87d9f50d0cebd4fc71c3542.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/appsstoremarket/alt/Y29tLWFidHV0b3JpYWwxMC1jYW5hZGFseWZ0LTItNDE4NzgwMzktYWQ0N2MxN2RjODdkOWY1MGQwY2ViZDRmYzcxYzM1NDI.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 27, 'pdownloads': 27, 'rating': {'avg': 5, 'total': 1}, 'prating': {'avg': 5, 'total': 1}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 41989617, 'name': 'Lyft', 'package': 'com.abtutorial10.canadalyft2', 'uname': 'com-abtutorial10-canadalyft2', 'size': 2342287, 'icon': 'http://pool.img.xxxxxxx.com/apps018/85767fc7ff03601ce1325fdedd9cf0dd_icon.png', 'graphic': 'http://pool.img.xxxxxxx.com/apps018/f0687693ea3eb5116894509683fa3f9d_fgraphic_705x345.jpg', 'added': '2018-11-21 08:04:06', 'modified': '2018-11-21 08:04:07', 'updated': '2018-11-21 08:04:07', 'uptype': 'regular', 'store': {'id': 2273237, 'name': 'apps018', 'avatar': 'http://pool.img.xxxxxxx.com/apps018/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 176, 'subscribers': 38, 'downloads': 23996}}, 'file': {'vername': '2.1', 'vercode': 2, 'md5sum': '0b4c234a748a6c42bb6c86f56787cf10', 'filesize': 2342287, 'path': 'http://pool.apk.xxxxxxx.com/apps018/com-abtutorial10-canadalyft2-2-41989617-0b4c234a748a6c42bb6c86f56787cf10.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/apps018/alt/Y29tLWFidHV0b3JpYWwxMC1jYW5hZGFseWZ0Mi0yLTQxOTg5NjE3LTBiNGMyMzRhNzQ4YTZjNDJiYjZjODZmNTY3ODdjZjEw.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 8, 'pdownloads': 8, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 41879202, 'name': 'Lyft', 'package': 'com.abtutorial10.canadalyft8', 'uname': 'com-abtutorial10-canadalyft8', 'size': 2342339, 'icon': 'http://pool.img.xxxxxxx.com/originalyes/85767fc7ff03601ce1325fdedd9cf0dd_icon.png', 'graphic': 'http://pool.img.xxxxxxx.com/originalyes/c83abedbcad184c9f8ce6856dd63274e_fgraphic_705x345.jpg', 'added': '2018-11-16 08:37:55', 'modified': '2018-11-16 08:37:56', 'updated': '2018-11-16 08:37:56', 'uptype': 'regular', 'store': {'id': 2268473, 'name': 'originalyes', 'avatar': 'http://pool.img.xxxxxxx.com/originalyes/da3bd21b288e5f980cc44ff6953fd9e5_ravatar.png', 'appearance': {'theme': 'pink', 'description': ''}, 'stats': {'apps': 151, 'subscribers': 33, 'downloads': 25408}}, 'file': {'vername': '2.1', 'vercode': 2, 'md5sum': 'd8c749ad0e7523c7887b029d52bc0411', 'filesize': 2342339, 'path': 'http://pool.apk.xxxxxxx.com/originalyes/com-abtutorial10-canadalyft8-2-41879202-d8c749ad0e7523c7887b029d52bc0411.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/originalyes/alt/Y29tLWFidHV0b3JpYWwxMC1jYW5hZGFseWZ0OC0yLTQxODc5MjAyLWQ4Yzc0OWFkMGU3NTIzYzc4ODdiMDI5ZDUyYmMwNDEx.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 7, 'pdownloads': 7, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 31174138, 'name': 'Surge Chaser for Lyft', 'package': 'com.uplyftprime', 'uname': 'surge-chaser-for-lyft', 'size': 9885571, 'icon': 'http://pool.img.xxxxxxx.com/devlindelfuego/6ae78524c53ca97c15c9b2befe58a3cc_icon.png', 'graphic': None, 'added': '2017-08-06 08:23:23', 'modified': '2017-08-06 08:23:24', 'updated': '2017-08-06 08:23:24', 'uptype': 'aptbackup', 'store': {'id': 1618717, 'name': 'devlindelfuego', 'avatar': 'http://pool.img.xxxxxxx.com/devlindelfuego/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 164, 'subscribers': 12, 'downloads': 3328}}, 'file': {'vername': '1.029', 'vercode': 30, 'md5sum': 'cc202eb8de4569095aec2f86b7265f94', 'filesize': 9885571, 'path': 'http://pool.apk.xxxxxxx.com/devlindelfuego/com-uplyftprime-30-31174138-cc202eb8de4569095aec2f86b7265f94.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/devlindelfuego/alt/Y29tLXVwbHlmdHByaW1lLTMwLTMxMTc0MTM4LWNjMjAyZWI4ZGU0NTY5MDk1YWVjMmY4NmI3MjY1Zjk0.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 10, 'pdownloads': 11, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': True, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 26296353, 'name': 'Lyft car hire', 'package': 'cc.snapp.app_lyft_car_hire', 'uname': 'lyft-car-hire', 'size': 49270686, 'icon': 'http://pool.img.xxxxxxx.com/snappbuilder/1a3e8d7ee63aee4ce41f4f09afc5eb6e.png', 'graphic': None, 'added': '2017-04-23 08:45:23', 'modified': '2017-04-23 08:45:23', 'updated': '2017-04-23 08:45:23', 'uptype': 'webservice', 'store': {'id': 992935, 'name': 'snappbuilder', 'avatar': 'http://pool.img.xxxxxxx.com/snappbuilder/4fd67e18c3369c00e55d58854466d4fb_ravatar.png', 'appearance': {'theme': 'lightsky', 'description': ''}, 'stats': {'apps': 11364, 'subscribers': 4879, 'downloads': 655515}}, 'file': {'vername': '1.9.2', 'vercode': 570313178, 'md5sum': 'a7475d8c27b7672f1020013847a8ea6e', 'filesize': 49270686, 'path': 'http://pool.apk.xxxxxxx.com/snappbuilder/cc-snapp-app-lyft-car-hire-570313178-26296353-a7475d8c27b7672f1020013847a8ea6e.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/snappbuilder/alt/Y2Mtc25hcHAtYXBwLWx5ZnQtY2FyLWhpcmUtNTcwMzEzMTc4LTI2Mjk2MzUzLWE3NDc1ZDhjMjdiNzY3MmYxMDIwMDEzODQ3YThlYTZl.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 2, 'pdownloads': 3, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 23145792, 'name': 'Assist4Lyft: Lyft Promo Codes', 'package': 'com.thelyftrider.lyftassist', 'uname': 'assist-4lyft', 'size': 5850532, 'icon': 'http://pool.img.xxxxxxx.com/vegasrome/199e862cf067a80d5ef93617ac7f14c8_icon.png', 'graphic': None, 'added': '2017-01-28 11:53:43', 'modified': '2017-01-28 11:53:43', 'updated': '2018-02-06 01:12:25', 'uptype': 'aptuploader', 'store': {'id': 52879, 'name': 'vegasrome', 'avatar': 'http://pool.img.xxxxxxx.com/vegasrome/3c9c3ea9ed74341c8a45890d6ea32fb3_ravatar.png', 'appearance': {'theme': 'black', 'description': 'Enjoy and keep in mind.. some of my uploads my require Lucky Patcher, Google Play Mod, and ROOT\r\nDo my best to bring you latest versions.'}, 'stats': {'apps': 8856, 'subscribers': 19216, 'downloads': 3672234}}, 'file': {'vername': '1.0', 'vercode': 1, 'md5sum': '817c42f6a997ef8bc60e54c61bbcfb71', 'filesize': 5850532, 'path': 'http://pool.apk.xxxxxxx.com/vegasrome/com-thelyftrider-lyftassist-1-23145792-817c42f6a997ef8bc60e54c61bbcfb71.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/vegasrome/alt/Y29tLXRoZWx5ZnRyaWRlci1seWZ0YXNzaXN0LTEtMjMxNDU3OTItODE3YzQyZjZhOTk3ZWY4YmM2MGU1NGM2MWJiY2ZiNzE.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 29, 'pdownloads': 30, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 21730958, 'name': 'FareWell', 'package': 'com.farewell', 'uname': 'robert-niimi-farewell', 'size': 8932627, 'icon': 'http://pool.img.xxxxxxx.com/yupofcourse/31d67d608e150feb9ab632c9be86d482_icon.png', 'graphic': None, 'added': '2016-11-08 04:49:30', 'modified': '2016-11-08 04:49:31', 'updated': '2017-01-28 11:50:44', 'uptype': 'aptbackup', 'store': {'id': 1077022, 'name': 'yupofcourse', 'avatar': 'http://pool.img.xxxxxxx.com/yupofcourse/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'pink', 'description': ''}, 'stats': {'apps': 2677, 'subscribers': 1792, 'downloads': 371478}}, 'file': {'vername': '1.0', 'vercode': 1, 'md5sum': 'e61d398585197b8ed0df2a08f79396b8', 'filesize': 8932627, 'path': 'http://pool.apk.xxxxxxx.com/yupofcourse/com-farewell-1-21730958-e61d398585197b8ed0df2a08f79396b8.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/yupofcourse/alt/Y29tLWZhcmV3ZWxsLTEtMjE3MzA5NTgtZTYxZDM5ODU4NTE5N2I4ZWQwZGYyYTA4Zjc5Mzk2Yjg.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 30, 'pdownloads': 30, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 39440400, 'name': 'Free Taxi Coupons For Lyft', 'package': 'com.pulsarappz.freetaxicouponsforlyft', 'uname': 'free-taxi-coupons-for-lyft', 'size': 5898638, 'icon': 'http://pool.img.xxxxxxx.com/lm2442/e919b13803869a85bfc01a44bea9f854_icon.png', 'graphic': None, 'added': '2018-08-09 05:58:07', 'modified': '2018-08-09 05:58:07', 'updated': '2018-08-09 05:58:07', 'uptype': 'aptuploader', 'store': {'id': 2173406, 'name': 'lm2442', 'avatar': 'http://pool.img.xxxxxxx.com/lm2442/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'black', 'description': 'Browns'}, 'stats': {'apps': 43, 'subscribers': 1, 'downloads': 68}}, 'file': {'vername': '1.9', 'vercode': 10, 'md5sum': 'a50e0aea81b50407bed88d1a46a8afed', 'filesize': 5898638, 'path': 'http://pool.apk.xxxxxxx.com/lm2442/com-pulsarappz-freetaxicouponsforlyft-10-39440400-a50e0aea81b50407bed88d1a46a8afed.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/lm2442/alt/Y29tLXB1bHNhcmFwcHotZnJlZXRheGljb3Vwb25zZm9ybHlmdC0xMC0zOTQ0MDQwMC1hNTBlMGFlYTgxYjUwNDA3YmVkODhkMWE0NmE4YWZlZA.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 8, 'pdownloads': 10, 'rating': {'avg': 5, 'total': 1}, 'prating': {'avg': 5, 'total': 1}}, 'has_versions': True, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 18107829, 'name': 'Lyft Taxi Bus Alternative', 'package': 'net.krwkfy.lyft.taxi.bus.alternative', 'uname': 'krwkfy-lyft-taxi-alternative', 'size': 4205039, 'icon': 'http://pool.img.xxxxxxx.com/helenayzes/3d153d49aa7ddd882f95318bed089ad6.png', 'graphic': None, 'added': '2016-03-10 02:13:22', 'modified': '2016-03-10 02:13:22', 'updated': '2016-03-10 02:13:22', 'uptype': 'webservice', 'store': {'id': 949999, 'name': 'helenayzes', 'avatar': 'http://pool.img.xxxxxxx.com/helenayzes/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 21, 'subscribers': 5, 'downloads': 2182}}, 'file': {'vername': '8.1.1008', 'vercode': 392145239, 'md5sum': '9ca5a51a6e7ba88465676201c25d1291', 'filesize': 4205039, 'path': 'http://pool.apk.xxxxxxx.com/helenayzes/net-krwkfy-lyft-taxi-bus-alternative-392145239-18107829-9ca5a51a6e7ba88465676201c25d1291.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/helenayzes/alt/bmV0LWtyd2tmeS1seWZ0LXRheGktYnVzLWFsdGVybmF0aXZlLTM5MjE0NTIzOS0xODEwNzgyOS05Y2E1YTUxYTZlN2JhODg0NjU2NzYyMDFjMjVkMTI5MQ.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 13, 'pdownloads': 13, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 23075890, 'name': 'Fare Compare Uber, Lyft & Taxi', 'package': 'com.zailoo.xroads', 'uname': 'goa2b', 'size': 8712680, 'icon': 'http://pool.img.xxxxxxx.com/moshkosh/afd317768d4e241c2f6b86dea7810464_icon.png', 'graphic': None, 'added': '2017-01-21 09:30:00', 'modified': '2017-01-21 09:30:01', 'updated': '2017-04-18 04:00:55', 'uptype': 'aptbackup', 'store': {'id': 1128043, 'name': 'moshkosh', 'avatar': 'http://pool.img.xxxxxxx.com/moshkosh/31d3c02ce8ddbeaa844ba1b0aa1d6cb2_ravatar.jpg', 'appearance': {'theme': 'light-blue', 'description': "Everything you want, Nothing you need.. \nOn a real note though, I upload the apps I frequent as well as the one timers I don't."}, 'stats': {'apps': 2333, 'subscribers': 165, 'downloads': 52338}}, 'file': {'vername': '2.1.0', 'vercode': 10148, 'md5sum': 'fc91fbde809abb73e259563820aa2593', 'filesize': 8712680, 'path': 'http://pool.apk.xxxxxxx.com/moshkosh/com-zailoo-xroads-10148-23075890-fc91fbde809abb73e259563820aa2593.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/moshkosh/alt/Y29tLXphaWxvby14cm9hZHMtMTAxNDgtMjMwNzU4OTAtZmM5MWZiZGU4MDlhYmI3M2UyNTk1NjM4MjBhYTI1OTM.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 8, 'pdownloads': 10, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': True, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 5971395, 'name': 'lyft uber easy taxi cabs', 'package': 'thetaxiapp.com', 'uname': 'lyft-uber-easy-taxi-cabs', 'size': 3442701, 'icon': 'http://pool.img.xxxxxxx.com/shaddon-green/ecb0e8b1ce78b612c06288cb194d6818_icon.png', 'graphic': None, 'added': '2014-06-04 06:38:56', 'modified': '2014-06-04 06:38:56', 'updated': '2014-06-04 06:38:56', 'uptype': 'aptbackup', 'store': {'id': 120645, 'name': 'shaddon-green', 'avatar': 'http://pool.img.xxxxxxx.com/shaddon-green/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'indigo', 'description': ''}, 'stats': {'apps': 1255, 'subscribers': 697, 'downloads': 115051}}, 'file': {'vername': '6.1.0.0.14', 'vercode': 177, 'md5sum': 'edddd6358e0c60b15caef4322341d3ff', 'filesize': 3442701, 'path': 'http://pool.apk.xxxxxxx.com/shaddon-green/thetaxiapp-com-177-5971395-edddd6358e0c60b15caef4322341d3ff.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/shaddon-green/alt/dGhldGF4aWFwcC1jb20tMTc3LTU5NzEzOTUtZWRkZGQ2MzU4ZTBjNjBiMTVjYWVmNDMyMjM0MWQzZmY.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 303, 'pdownloads': 294, 'rating': {'avg': 5, 'total': 2}, 'prating': {'avg': 5, 'total': 2}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 37966226, 'name': 'Free Taxi Ride Coupons for Lyft', 'package': 'com.appfactory.taxicouponslyft', 'uname': 'taxi-coupons-lyft', 'size': 4902371, 'icon': 'http://pool.img.xxxxxxx.com/vivo-api/699da34f6b1cede35beda1f20ffa600d_icon.png', 'graphic': None, 'added': '2018-06-08 02:22:53', 'modified': '2018-06-08 02:22:53', 'updated': '2018-06-08 02:22:53', 'uptype': 'webservice', 'store': {'id': 1463246, 'name': 'vivo-api', 'avatar': 'http://pool.img.xxxxxxx.com/vivo-api/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 123417, 'subscribers': 6878, 'downloads': 4220618}}, 'file': {'vername': '1.2', 'vercode': 3, 'md5sum': 'a7fcb7844b897b95d2f8fd9dae6d716d', 'filesize': 4902371, 'path': 'http://pool.apk.xxxxxxx.com/vivo-api/com-appfactory-taxicouponslyft-3-37966226-a7fcb7844b897b95d2f8fd9dae6d716d.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/vivo-api/alt/Y29tLWFwcGZhY3RvcnktdGF4aWNvdXBvbnNseWZ0LTMtMzc5NjYyMjYtYTdmY2I3ODQ0Yjg5N2I5NWQyZjhmZDlkYWU2ZDcxNmQ.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 8, 'pdownloads': 8, 'rating': {'avg': 5, 'total': 1}, 'prating': {'avg': 5, 'total': 1}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 38283734, 'name': 'Free Ride Promos for Lyft Cab', 'package': 'com.shineappzz.newlyftcoupons', 'uname': 'newlyftcoupons-big-shine-team', 'size': 4217943, 'icon': 'http://pool.img.xxxxxxx.com/legacyapps13/1d630b774f661acaace44e9f54f43f71_icon.png', 'graphic': None, 'added': '2018-06-20 16:23:24', 'modified': '2018-06-20 16:23:24', 'updated': '2018-06-20 16:23:24', 'uptype': 'aptuploader', 'store': {'id': 2025398, 'name': 'legacyapps13', 'avatar': 'http://pool.img.xxxxxxx.com/legacyapps13/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'default', 'description': ''}, 'stats': {'apps': 84, 'subscribers': 44, 'downloads': 19482}}, 'file': {'vername': '1.0', 'vercode': 1, 'md5sum': 'b6df2843e8025eac0b10853f1af3fcb6', 'filesize': 4217943, 'path': 'http://pool.apk.xxxxxxx.com/legacyapps13/com-shineappzz-newlyftcoupons-1-38283734-b6df2843e8025eac0b10853f1af3fcb6.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/legacyapps13/alt/Y29tLXNoaW5lYXBwenotbmV3bHlmdGNvdXBvbnMtMS0zODI4MzczNC1iNmRmMjg0M2U4MDI1ZWFjMGIxMDg1M2YxYWYzZmNiNg.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 3, 'pdownloads': 3, 'rating': {'avg': 5, 'total': 1}, 'prating': {'avg': 5, 'total': 1}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}, {'id': 39440422, 'name': 'Taxi Coupons for Lyft - Canada & USA', 'package': 'com.pulsarappz.couponsforlyft_usandcanada', 'uname': 'coupons-for-lyft-us-and-canada', 'size': 6186897, 'icon': 'http://pool.img.xxxxxxx.com/lm2442/f561c396db660e6989ea894953166976_icon.png', 'graphic': None, 'added': '2018-08-09 05:59:09', 'modified': '2018-08-09 05:59:10', 'updated': '2018-08-09 05:59:10', 'uptype': 'aptuploader', 'store': {'id': 2173406, 'name': 'lm2442', 'avatar': 'http://pool.img.xxxxxxx.com/lm2442/3bf5adf05843f9f28c486d5ddef8f873_ravatar.jpg', 'appearance': {'theme': 'black', 'description': 'Browns'}, 'stats': {'apps': 43, 'subscribers': 1, 'downloads': 68}}, 'file': {'vername': '5.0', 'vercode': 5, 'md5sum': 'afc9cb352de940d11b5e0a1437261d4c', 'filesize': 6186897, 'path': 'http://pool.apk.xxxxxxx.com/lm2442/com-pulsarappz-couponsforlyft-usandcanada-5-39440422-afc9cb352de940d11b5e0a1437261d4c.apk', 'path_alt': 'http://pool.apk.xxxxxxx.com/lm2442/alt/Y29tLXB1bHNhcmFwcHotY291cG9uc2Zvcmx5ZnQtdXNhbmRjYW5hZGEtNS0zOTQ0MDQyMi1hZmM5Y2IzNTJkZTk0MGQxMWI1ZTBhMTQzNzI2MWQ0Yw.apk', 'malware': {'rank': 'UNKNOWN'}}, 'stats': {'downloads': 2, 'pdownloads': 2, 'rating': {'avg': 0, 'total': 0}, 'prating': {'avg': 0, 'total': 0}}, 'has_versions': False, 'obb': None, 'appcoins': {'advertising': False, 'billing': False}}]
from pandas.io.json import json_normalize
df = json_normalize(data)
df.to_csv('file.csv', index=False)

Categories

Resources