2

simple question. I have a text file containing JSON objects which hold real estate information, like so:

     {
      "marketing_package_url": "http://www.capitalpacific.com/inquiry/TrailsEndMarketplaceExecSummary.pdf",
     "title": "TRAILS END MARKETPLACE",
      "location": "OREGON CITY, OR"
      }

In my script, I have a list of marketing package URLS. I want to cross-check the URLS from that list with the URL's in the json objects in this text file so I can find the 'new' URLS. Any suggestions? I was thinking along the lines of importing the json objects into a separate list, and then using the URL's from that list.

import json
with open('properties.txt', 'r') as filename:
           data = json.loads('properties.txt')

how to split it up and send URLS to a list?

1
  • Can you show what data looks like? import pprint; pprint.pprint(data) would be helpful Commented Mar 6, 2015 at 6:03

1 Answer 1

3

You can use the following code to get the list of marketing_package_urls to list, if the data is a list of dictionaries.

list = [x['marketing_package_url'] for x in data]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.