0

In Patrick Loeber's How to Analyze Apple Health Data with Python (https://www.python-engineer.com/posts/apple-health-data-python/), he suggests iterating over 'Workouts' here: workout_list = [x.attrib for x in root.iter('Workout')]. How does he know 'Workout' is an element within the tree? Thx!

I've tried looking at the tree iter, elem, root.tag, root.attrib, for child in root, but can't seem to figure out how he knows 'Workouts' is an element in the tree.

  • 4
    Well, if you are going to write an article about working with some data, you should know what format data comes in. i.e. he is familiar with the format exported from this iPhone Health App – buran Mar 02 '23 at 14:23
  • You can check child.tag for every child of the root and find an interesting one. – Kuroneko Mar 02 '23 at 14:25
  • It's an assumption based on the expected contents of `data.Export.xml`, not something that's guaranteed by the `ElementTree` type. – chepner Mar 02 '23 at 14:50
  • Thanks! That helps as I was banging my head against the way trying to figure out how to pull that from the tree. I knew it was in there because I'd parsed the data into CSV files and saw it as a CSV, but was wondering if there was a means of seeing it with PY. – VectorLue Mar 02 '23 at 16:07
  • Please improve you question: Add your python code what you have tried to work and your input file structure with dummy data, if you assume help. – Hermann12 Mar 02 '23 at 16:24

0 Answers0