A Python Project that Converts csv or excel data to json |Datascience |Numpy|pandas|PythonLibraries
HTML-код
- Опубликовано: 4 сен 2021
- Find the:
python script
drive.google.com/file/d/10qhP...
datasheet
drive.google.com/file/d/1oRNr...
In this video, I will show you how to use python to convert excel or CSV data into JSON data.
This may be necessary if you want to update or populate a database.
e.g. firebase real-time database
SUBSCRIBE FOR MORE VIDEOS LIKE THIS
#python project #anaconda spyder #Geomatics #Engineering #coders #GIS #Autocad #QGIS #EngineeringConcepts Наука
Like your video. I have a question: How can I modify the code so that it prints a Json file but just of each line separately?
In that case, you will have to write a loop (for loop) to create a dataframe and export it at every instance.
I think that should do it.
Each element is having a curly bracket how t o get rid of it
If you notice from the video, I used curly braces for each elements and it’s value . At the end of the day, I’ll get a list of dictionaries which contain nested dictionaries.
If you want to get rid of the nested dictionaries, then you should not use it in the definition like I did in the video. You should just do something like; proGeomatics = {‘name’:”Pro Geomatics”, “age”: 2}
I hope you get it?
Essentially, if you don’t want to see extra dictionaries in your output, then avoid them in your definitions
How to get rid of the index numbers from the json file in ur code , my requirement of json is to have all key values under one tag as am trying to post that to an aws API
I’m not sure I understand what you are asking. But to a json file has the same structure as a dictionary which is a key-value structure.
If you remove the index (key), you won’t be able to call a particular value because they won’t be unique.
Perhaps I didn’t understand your question properly, so feel free to rephrase and I’ll be happy to help
@@ProGeomatics am actually creating a json for api post. I followed ur video to create the json and its a nested json .
While creating json am using the counter inside the container , because all my keys are similar string
Like
Container [count] = {"abc": df.abc[count],
"xyz": df.xyz[count]}
Json is like
"0":{"abc":"axyrd", "xyz":"2536"}
"1":{"abc":"sded", "3478"}
The key 0,1 keeps on increasing until it hits the end, but my api post needs only json data not the indexes, and throwing error
Ok, let’s see.
The container here is a dictionary
Container = {}
We loop though to add data to it
While x
@@ProGeomatics not exactly!
Container [df.abc[count]] this particular value i want it to be a key value not only value
The key of your dictionary I.e. container[df.abc[‘count’] has to be unique
I don’t think you can make a dictionary the key of your dictionary.
You can contact me through my email on the channels about section and we can discuss it further
What is uni_name In parameters?
Uni_name is just a variable I created to stand for the university names. It’s just a variable I defined up in the script.