Тёмный

How to Convert CSV to JSON in Python 

Python Tutorials for Digital Humanities
Подписаться 26 тыс.
Просмотров 35 тыс.
50% 1

In this video, I show you how to easily convert CSV files into JSON files.
If you enjoy this video, please subscribe. I provide all my content at no cost. If you want to support my channel, please donate via
PayPal: www.paypal.com/cgi-bin/webscr...
Patreon: / wjbmattingly (its my www.themedievalworld.com account as well).
If there's a specific video you would like to see or a tutorial series, let me know in the comments and I will try and make it.
If you liked this video, check out www.PythonHumanities.com, where I have Coding Exercises, Lessons, on-site Python shells where you can experiment with code, and a text version of the material discussed here.
You can follow me at:
/ wjb_mattingly

Опубликовано:

 

20 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 45   
@RyanC119
@RyanC119 Год назад
Incredibly helpful and clearly explained. Thank you!
@chessketeer
@chessketeer Год назад
Very clear, very helpful, very simple, very GREAT.
@andrejsopsis6109
@andrejsopsis6109 Год назад
Thnak you , at most about last minute without "names"
@saucecode5544
@saucecode5544 Год назад
Thanks for the tutorial. Even after 2 years, this video was useful. Now I can use this to create api's
@python-programming
@python-programming Год назад
No problem! You can also use pandas. I have been thinking of doing that video too
@aravindjeffhardy
@aravindjeffhardy 2 года назад
Very Nice, It helped me a lot. Thank you so much
@mankind770
@mankind770 2 года назад
Awesome !!! Much thanks mate
@henriquebalzani1563
@henriquebalzani1563 2 года назад
OMG!! thank you... Just what I needed it
@python-programming
@python-programming 2 года назад
Glad it helped!
@defaultname1700
@defaultname1700 Год назад
This video solved a myriad of problems, thanks
@python-programming
@python-programming Год назад
So happy to hear that!
@JoeCole_social
@JoeCole_social 3 года назад
This saved me so much time thank you so much! please consider some sort of tip jar so I can contribute and support your efforts.
@python-programming
@python-programming 3 года назад
I'm very pleased it helped you! Right now, I just use Paypal's donation: www.paypal.com/donate/?cmd=_donations&business=AZ73QW52SUX8N&currency_code=USD&source=url Thanks for the contribution!
@andrewburnley917
@andrewburnley917 Год назад
This is awesome!
@ola419rrie
@ola419rrie 2 года назад
Thanks for this tutorial, what if our CSV file had more rows and we wanted to append some of the rows to form nested dictionaries.
@14silber
@14silber 3 года назад
Thanks for your video
@kyleb3316
@kyleb3316 2 года назад
Great tutorial, do you have another where you go into more nested dictionaries?
@python-programming
@python-programming 2 года назад
Thanks! I do not at the moment. The process will work the same regardless of the data structure. It is just a matter of accessing the nested data via Python.
@xXCLAVERYXx
@xXCLAVERYXx 2 года назад
Hi Thanks for this but how could I limit the size as Im using a large dataset and only really want about 1000 records.
@honaidaattaher4549
@honaidaattaher4549 2 года назад
thank you so much
@amitdighe1
@amitdighe1 3 года назад
Thanks for your video, the only problem I am facing here is after the conversion, the order of the fields is not maintained in JSON file as of CSV. Do you have any workaround on that?
@python-programming
@python-programming 3 года назад
Hmmm... can you paste a sample of the json and the csv?
@AndyArismendi
@AndyArismendi Год назад
I know this is a python tutorial but for what it's worth, the equivalent in powershell: @{Names = (Import-Csv names.csv)} | ConvertTo-Json
@KhalilYasser
@KhalilYasser 3 года назад
Awesome. Thank you very much. In the json output I noticed that the numbers are like strings. How can I make numbers as integers (without quotations in the json output)?
@python-programming
@python-programming 3 года назад
Good question. Before outputting to JSON, insure that your integer or float is not a string by converting it with int("STRING GOES HERE") or float()
@KhalilYasser
@KhalilYasser 3 года назад
@@python-programming Can you guide me on what line should I modify? Do you mean in that part `int(row[1]`
@python-programming
@python-programming 3 года назад
@@KhalilYasser Of course. So line 10 I would change row[1] to int(row[1]) --- I haven't tested this, but that will convert any instance of a string to an integer
@KhalilYasser
@KhalilYasser 3 года назад
@@python-programming Amazing. I have tested and it worked well. Thank you very much.
@python-programming
@python-programming 3 года назад
@@KhalilYasser Yay! Excellent. Glad I could help. No worries at all.
@SkyOcean-lg7lt
@SkyOcean-lg7lt Год назад
What a God you are!
@KiranKumar-zb6ly
@KiranKumar-zb6ly 2 года назад
Sir what we want to do if we want to convert only particular columns of csv file into json. plz reply quickly
@mankind770
@mankind770 2 года назад
Is this method okay for when working with large set of data. I mean getting the row number might not be always easy
@Shubhankar.Banerjee
@Shubhankar.Banerjee 2 года назад
Text size is very small. Difficult to read text on mobile screen.
@manmeetkaur4472
@manmeetkaur4472 2 года назад
Hi, its a great code but I have a question here, If I want the output as {Bob:28, Fred:32, Jim:35}.... Don't want the header as keys.......just want both the columns as keys and values in one dictionary. How can I do that?
@LimpiaPeceras
@LimpiaPeceras 3 года назад
Hi! Thanks for the video. I have one error when I try to read the json "'utf-8' codec can't decode byte 0xff in position 0: invalid start byte". Could you help me? Thanks
@python-programming
@python-programming 3 года назад
Hi! It is hard to tell without seeing your data, but it sounds like an encoding error. You will need to figure out what encosing your data is using and load it as that rather than utf-8 or pass an error arugment to skip characters that return an error.
@SaysAnX
@SaysAnX Год назад
y con un csv que se tiene en drive?
@mehakrani3614
@mehakrani3614 2 года назад
can you convert csv to arff data format ?
@olatundeibrahim8355
@olatundeibrahim8355 Год назад
Hello. This method is not working for csv file with larger number of rows and columns. Can someone please assist?
@python-programming
@python-programming Год назад
If you are familiar with pandas, you can load it up in pandas with read csv and then save it with to json. Remmeber to set index to False
@ironfrogclark
@ironfrogclark 2 года назад
what IDE are you using?
@python-programming
@python-programming 2 года назад
Atom for this video
@kaushikrana5680
@kaushikrana5680 2 года назад
Hey , how to make multiple keys ?? Like : { "AB" : { "..." : { "..." : {"..." , "....." } } } }
@python-programming
@python-programming 2 года назад
Csv files are not good at storing this type of data structure. You are better off leaving it as a JSON file.
Далее
JSON Tutorial in Python
13:22
Просмотров 59 тыс.
Qizim 58-qism | Anons |Nimaga meni bolam o'ladi ?
00:47
If __name__ == "__main__" for Python Developers
8:47
Просмотров 387 тыс.
Convert CSV to JSON with Python
8:32
Просмотров 37 тыс.
This Is Why Python Data Classes Are Awesome
22:19
Просмотров 796 тыс.
ASMR Programming - Spinning Cube - No Talking
20:45
Просмотров 3,7 млн
Handling JSON data with Python
18:44
Просмотров 66 тыс.
Convert JSON To CSV in seconds with jq ⏱️
5:51
Просмотров 7 тыс.
CSV To JSON With Python Pandas
8:16
Просмотров 11 тыс.
Qizim 58-qism | Anons |Nimaga meni bolam o'ladi ?
00:47