I am retrieving a SOAP envelope from an endpoint and then attempting to pull the data from the fields. I'm using simplified_scrapy and this has worked correctly but for empty values, it throws an error. The SOAP/xml string is loaded into a variable and then I am parsing that looking for my specified head tag. I'm writing the values to a csv using the below code if there is a tag that does not have a value in it I get the error:
File "C:/Users/syorke/PycharmProjects/DMBStart/API/GoodScripts/DebtsGetDebts.py", line 45, in <module>
, c.SettlementStatus.text
AttributeError: 'List' object has no attribute 'text
In the code below the tag SettlementStatus is the field that has no value:
fh.write(cols)
for c in Categories:
fh.write('%s\n' % [(c.FileNumber.text
, c.DebtId.text
, c.VendorId.text
, c.DebtType.text
, c.SettlementStatus.text
# , c.AccountStatus.text
, c.IsStatementIncluded.text
, c.PrimaryName.text
, c.ApplicantType.text
, c.OriginalBalance.text
, c.MinimumPayment.text
)])
fh.close()
I've tried adding an if around the tab essentially say if there is a value to write the value else write '' but this did not work. Thanks for any pointers or assistance.