Skip to content

Instantly share code, notes, and snippets.

@icoxfog417
Created November 20, 2019 10:01
Show Gist options
  • Save icoxfog417/30e25cfeb60023c1e16bacc4678db99b to your computer and use it in GitHub Desktop.
Save icoxfog417/30e25cfeb60023c1e16bacc4678db99b to your computer and use it in GitHub Desktop.
xbrl_data = []
for i, row in data.iterrows():
tag_name = row["element"]
for n in namespaces:
if tag_name.startswith(n):
tag_name = f"{n}:{tag_name.replace(n + '_', '')}"
break
tag = xbrl.find(tag_name)
element = tag.element
if element is None:
continue
item = {}
for k in data.columns:
item[k] = row[k]
for i in range(parent_depth):
parent_label = data[data["element"] == row[f"parent_{i}"]]["label"]
item[f"parent_{i}_name"] = "" if len(parent_label) == 0 else parent_label.tolist()[0]
item["value"] = element.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment