JSON To CSV using Python

  Рет қаралды 15,161

bugandcode

bugandcode

Күн бұрын

In this video we will convert a JSON object to CSV using python. The code for this video is located in the GitHub repo:
github.com/bug...

Пікірлер: 12
@akbarxojaabduraximov7427
@akbarxojaabduraximov7427 Жыл бұрын
import json def export_to_csv(): with open("D:/Scripting/ToShPfile.json") as f: list1 = [] ToShPfile = json.loads(f.read()) temp = ToShPfile[0] header_items = [] get_header_items(header_items, temp) list1.append(header_items) for obj in ToShPfile: d = [] add_items_to_ToShPfile(d, obj) list1.append(d) with open ('output.csv', 'w') as output_file: for a in list1: output_file.write(','.join(map(str, a)) + " ") def get_header_items(items, obj): for x in obj: if isinstance(obj[x], dict): items.append(x) get_header_items(items, obj[x]) else: items.append(x) def add_items_to_ToShPfile(items, obj): for x in obj: if isinstance(obj[x], dict): items.append("") get_header_items(items, obj[x]) else: items.append(obj[x]) export_to_csv()
@soulmusic9274
@soulmusic9274 11 ай бұрын
in def add_items_to_ToShPfile change get_header_items to add_items_to_ToShPfile
@millertk
@millertk 2 күн бұрын
@@soulmusic9274 Yeah, he made this error in the video and then corrected himself. Whomever put the code in the comments used that version before he fixed it to be recursive.
@akashkumar-m5u9n
@akashkumar-m5u9n Жыл бұрын
not able to see csv in table form
@iam9_39
@iam9_39 6 ай бұрын
❤❤❤ thanks a lot
@abisandy1481
@abisandy1481 11 ай бұрын
My json file structure is [ { "attributes":{ "Phone" : [ { "Label": "abcd" "Value":{ " Type":[ { "Type": " Xyz" } ] In this structure, how could i read key values?
@xx-jl3gl
@xx-jl3gl Жыл бұрын
Thank you! It works perfectly
@AshishKumar-us2nd
@AshishKumar-us2nd Жыл бұрын
Thanks! Great help
@sujitreddy7702
@sujitreddy7702 Жыл бұрын
Hey how can I contact you? I need some help with modifying this use case a bit.
@akbarxojaabduraximov7427
@akbarxojaabduraximov7427 Жыл бұрын
Hello, I had a problem, I wrote a script according to your instructions and as a result I get only columns, and the data in these columns is not exported
@soulmusic9274
@soulmusic9274 11 ай бұрын
time 12:01 is solution
@marcosd3976
@marcosd3976 Жыл бұрын
key typiyng is anoying
Python Tutorial: Working with JSON Data using the json Module
20:34
Corey Schafer
Рет қаралды 1,1 МЛН
Using Python to Fetch API Data into CSV
5:24
Daniel Otto
Рет қаралды 32 М.
How Strong is Tin Foil? 💪
00:26
Preston
Рет қаралды 140 МЛН
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 43 МЛН
Python JSON Parsing: A Step-by-Step Guide to Extract Data from JSON
14:27
Automate with Rakesh
Рет қаралды 19 М.
Converting Complex JSON to Pandas DataFrame
4:48
Epython Lab
Рет қаралды 3,6 М.
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,5 МЛН
5 Good Python Habits
17:35
Indently
Рет қаралды 546 М.
10 Python Comprehensions You SHOULD Be Using
21:35
Tech With Tim
Рет қаралды 149 М.
Json to csv convert using python easily
6:02
IT TECH TARUN
Рет қаралды 39 М.
JSON TO CSV using JavaScript
14:42
bugandcode
Рет қаралды 1 М.
Request API data using Python in 8 minutes! ↩️
8:34
Bro Code
Рет қаралды 13 М.