Python non iterable data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Python non iterable data
# 1  
Old 11-26-2015
Python non iterable data

I have a data of this format which I am trying to parse in my python script:
Code:
{
    "mydict": [
        {
            "DATA1": "USA",
            "DATA2": true,
            "DATA3": "878473e923jsjdhsjdfh38980",
          },
        {
            "DATA1": "UK",
            "DATA2": false,
            "DATA3": "zscj27r87878r7jhdkjasdjksa",
        }
    ]
}

Is there a way to get corresponding value of DATA3 of the set containing DATA1 as "UK" using python? I tried dictionary iteration but its failing.
# 2  
Old 11-26-2015
Code:
>>> a_dict['mydict'][1]['DATA1']
'UK'
>>> a_dict['mydict'][1]['DATA3']
'zscj27r87878r7jhdkjasdjksa'
>>>

This User Gave Thanks to Aia For This Post:
# 3  
Old 11-30-2015
Actually my data had no quotes on the second item where true and false values where appearing. That's why my dictionary call was not working. I am now trying to figure how to replace this sting to convert it to a dictionary.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pass some data from csv to xml file using shell/python

Hello gurus, I have a csv file with bunch of datas in each column. (see attached) Now I have an .xml file in the structure of below: ?xml version="1.0" ?> <component id="root" name="root"> <component id="system" name="system"> <param name="number_of_A" value="8"/> ... (5 Replies)
Discussion started by: Zam_1234
5 Replies

2. UNIX for Dummies Questions & Answers

Maximum number of data in Python

Hi all, I would like to save my output data in two columns. I tried print(x,y) but have two problems: 1. There are ~10000 values for each x and y, but the intermediates are omitted; 2. I'd like to list data in two columns instead of two arrays (BTW, it's fine as I can format it using other... (3 Replies)
Discussion started by: sxiong
3 Replies

3. Programming

Python script for extracting data using two files

Hello, I have two files. File 1 is a list of interested IDs Ex1 Ex2 Ex3File 2 is the original file with over 8000 columns and 20 millions rows and is a compressed file .gz Ex1 xx xx xx xx .... Ex2 xx xx xx xx .... Ex2 xx xx xx xx ....Now I need to extract the information for all the IDs of... (4 Replies)
Discussion started by: nans
4 Replies

4. Shell Programming and Scripting

Python FTP login and relogin with other data in one wash?

I have a short part of the script like this, which scrans ftp ips from a list and login with the data specified. login1 pssword1is it possible to try sevral login data without starting the script again with modified login data? somehow like: if (login1 pw1 or login2 pw2 or login3 pw3) {... (0 Replies)
Discussion started by: lowmaster
0 Replies

5. Shell Programming and Scripting

Use PYTHON to collect data weather and print in new file

Hi all, i have a task to do with Python and because i'm a beginner on it i would like your help on this. Create a python script that: Every hour collect the Temperature (e.g. 29C) and Current Condition (e.g. Clear) from this website wunderground.com/global/stations/54511.html Create a CSV... (0 Replies)
Discussion started by: ragaga123
0 Replies

6. Shell Programming and Scripting

Bash script with python slicing on multiple data files

I have 2 files generated in linux that has common output and were produced across multiple hosts with the same setup/configs. These files do some simple reporting on resource allocation and user sessions. So, essentially, say, 10 hosts, with the same (2) system reporting in the files, so a... (0 Replies)
Discussion started by: jdubbz
0 Replies

7. Shell Programming and Scripting

Using Python to grab data from a website

Hello Everyone, I'm trying to write a python script that will go to the following website and grab all the data on the page. The page refreshes regularly and the number of flights is different. Untitled Document What I wanted to do was grab all the data (except for top three row containing... (5 Replies)
Discussion started by: jl487
5 Replies
Login or Register to Ask a Question