1
votes

Hi I'm trying to get the '/Title' value in the following dictionary/array. As you can see theres a mix of a plain dictionary, followed by an array with nested dictionary then further arrays and this pattern of a single dictionary then the mess repeats throughout the full text(this is just a snippet).

What is the pythonic way to retrieve the '/Title' value? Any help or pointer is very much appreciated thank you.

{'/Title': '12 Place Holder Text', '/Page': IndirectObject(5069, 0), '/Type': '/Fit'}

[{'/Title': '12.1 Place Holder Text', '/Page': IndirectObject(5074, 0), '/Type': '/Fit'}, 
 [{'/Title': '12.1.1 Place Holder Text', '/Page': IndirectObject(5074, 0), '/Type': '/Fit'}, 
  {'/Title': '12.1.2 Place Holder Text', '/Page': IndirectObject(5076, 0), '/Type': '/Fit'}, 
  {'/Title': '12.1.3 Place Holder Text', '/Page': IndirectObject(5092, 0), '/Type': '/Fit'}], 
 {'/Title': '12.2 Place Holder Text', '/Page': IndirectObject(5120, 0), '/Type': '/Fit'}, 
 [{'/Title': '12.2.1 Place Holder Text', '/Page': IndirectObject(5120, 0), '/Type': '/Fit'}, 
  {'/Title': '12.2.2 Place Holder Text', '/Page': IndirectObject(5121, 0), '/Type': '/Fit'}, 
  {'/Title': '12.2.3 Place Holder Text', '/Page': IndirectObject(5121, 0), '/Type': '/Fit'}]
Which Title are you trying to get, and what have you tried to get it?Scott Hunter
All of them. I've tried using .get() and tried .find() and .split() on the dictionary by converting to a string. Just repeated errors that don't lead me anywhere. I thought it was a simple for loop but ain't been so easy.BillaBong Jr.