(Feb-20-2020, 12:07 PM)snippsat Wrote:(Feb-20-2020, 11:20 AM)jk91 Wrote: how should i make it according to my case also i just have eclispse software installed on my systemUse PyDev
PyDev Wrote:PyDev is a Python IDE for Eclipse
(Feb-20-2020, 11:20 AM)jk91 Wrote: i also tried to execute above code in colab but again it ended in error:-You shall not use it like this,i do it in two parts read file then doing some test in interactive interpreter>>>
.
The task will be hard without any basic knowledge of Python.
Here is what's indata.json
test file.
Output:{ "firstName": "Jane", "lastName": "Doe", "hobbies": [ "running", "sky diving", "singing" ], "age": 35, "children": [ { "firstName": "Alice", "age": 6 }, { "firstName": "Bob", "age": 8 } ] }# test_read.py import json from pprint import pprint with open("data.json", "r") as read_file: data = json.load(read_file) pprint(data)So now reading as a script
Output:{'age': 35, 'children': [{'age': 6, 'firstName': 'Alice'}, {'age': 8, 'firstName': 'Bob'}], 'firstName': 'Jane', 'hobbies': ['running', 'sky diving', 'singing'], 'lastName': 'Doe'}test_read.py
and run it,and i have to print the content.
Doing test in interactive interpreter>>>
,i do not need print.
>>> data {'age': 35, 'children': [{'age': 6, 'firstName': 'Alice'}, {'age': 8, 'firstName': 'Bob'}], 'firstName': 'Jane', 'hobbies': ['running', 'sky diving', 'singing'], 'lastName': 'Doe'} >>> >>> data['hobbies'] ['running', 'sky diving', 'singing'] >>> ', '.join(data['hobbies']) 'running, sky diving, singing' # Can also use print here >>> print(', '.join(data['hobbies'])) running, sky diving, singing >>>
if i just download pydev ide will it not require to install python separately also i am on windows 7 32 bit and tried to install sp1 for it but it's getting failed so alternatively someone advised me to use colab.
so with colab can't i just test above all?
(Feb-20-2020, 02:06 PM)jk91 Wrote:(Feb-20-2020, 12:07 PM)snippsat Wrote: Use PyDev
You shall not use it like this,i do it in two parts read file then doing some test in interactive interpreter>>>
.
The task will be hard without any basic knowledge of Python.
Here is what's indata.json
test file.
Output:{ "firstName": "Jane", "lastName": "Doe", "hobbies": [ "running", "sky diving", "singing" ], "age": 35, "children": [ { "firstName": "Alice", "age": 6 }, { "firstName": "Bob", "age": 8 } ] }# test_read.py import json from pprint import pprint with open("data.json", "r") as read_file: data = json.load(read_file) pprint(data)So now reading as a script
Output:{'age': 35, 'children': [{'age': 6, 'firstName': 'Alice'}, {'age': 8, 'firstName': 'Bob'}], 'firstName': 'Jane', 'hobbies': ['running', 'sky diving', 'singing'], 'lastName': 'Doe'}test_read.py
and run it,and i have to print the content.
Doing test in interactive interpreter>>>
,i do not need print.
>>> data {'age': 35, 'children': [{'age': 6, 'firstName': 'Alice'}, {'age': 8, 'firstName': 'Bob'}], 'firstName': 'Jane', 'hobbies': ['running', 'sky diving', 'singing'], 'lastName': 'Doe'} >>> >>> data['hobbies'] ['running', 'sky diving', 'singing'] >>> ', '.join(data['hobbies']) 'running, sky diving, singing' # Can also use print here >>> print(', '.join(data['hobbies'])) running, sky diving, singing >>>
if i just download pydev ide will it not require to install python separately also i am on windows 7 32 bit and tried to install sp1 for it but it's getting failed so alternatively someone advised me to use colab.
so with colab can't i just test above all?
also where do we save that data.json test file?also what is the type we give it while saving it and what should be the location of aving it and can we save it it in plain note pad text file?