On Thu, Sep 3, 2015 at 8:15 AM, kbtyo <ahlusar.ahluwa...@gmail.com> wrote: > However, when I hit line 40 (referencing the gist), I receive the following > error: > > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > <ipython-input-56-4eff0a608e19> in <module>() > 23 # to ensure that the field names in the XML don't match (and > override) the > 24 # field names already in the dictionary > ---> 25 row.update(xml_data) > 26 # ensure that the headers have all the right fields > 27 headers.update(row.keys()) > > TypeError: 'NoneType' object is not iterable > > I can only infer I am passing or converting an empty key or empty row. I > welcome feedback.
NoneType is the type of the singleton object None. So what this means is that xml_data is None at this point. In your just_xml_data() function, which is what provides xml_data at that point, there are two code branches that matter here: one is the "else: return xml", and the other is the implicit "return None" at the end of the function. If you catch an exception, you print out a message and then allow the function to return None. Is that really your intention? It seems an odd way to do things, but if that is what you want, you'll need to cope with the None return in the main routine. BTW, your gist has a couple of non-comments on lines 48 and 49. If you can make sure that your code is functionally correct, it'll be easier for us to test. (Even more so if you can include a sample input file in the gist, though preferably not a huge one.) At the moment, I'm just eyeballing the code itself, but if someone can actually run the script and reproduce the exact error you're seeing, it makes debugging that much easier. All the best! ChrisA -- https://mail.python.org/mailman/listinfo/python-list