Skip to content

Tag: python

Use a python list in a Socrata Request

I have connected to a public dataset using Socrata. As this dataset is very large, I would like to use a where statement in the .get statement to filter out certain records. I only want to import records for which I have matching records in my SQL database. I have created a Python list of these Id’s. I …

Read XML line by line without loading whole file to memory

This is structure of my XML: Can I load every row one by one without loading whole XML file into memory? For example printing all of the titles Answer Providing the XML file is structured exactly as shown in the example then BeautifulSoup could be used to parse relevant lines. Something like this:

How do I reduce multiple nested if statements in Python?

I’m working with a code snippet that iterates over an object list and filters out objects to perform a specific task. The for loop consists of multiple nested if statements (and I’ll probably add more in the future). Here’s my code: Is there a neat or efficient workaround for this snippet? P…