1. Technology

Part 2: Getting Feed Information From the Data File With Python

By

7 of 9

Reading the RSS Feed as a Python File Object

Now, we are ready to read from the file object. Every file object has several open, read, write, and close methods that can be called. The most common ones are discussed in my tutorials on file handling. For our purposes, we will read the file into a dictionary.

Before starting the iteration, we read one line into a variable line and initiate an empty dictionary. Let's call it record.

 line = datafile.readline() 
 record = {} 

If you need more help with dictionaries, you can get a quick tutorial or review in my beginner's tutorial.

  1. About.com
  2. Technology
  3. Python

©2014 About.com. All rights reserved.