hierarchical-data

How can I get certain levels of JSON in Python?

戏子无情 提交于 2020-01-06 07:54:41
问题 If my JSON data looks like this: { "name": "root", "children": [ { "name": "a", "children": [ { "name": "b", "children": [ { "name": "c", "size": "1" }, { "name": "d", "size": "2" } ] }, { "name": "e", "size": 3 } ] }, { "name": "f", "children": [ { "name": "g", "children": [ { "name": "h", "size": "1" }, { "name": "i", "size": "2" } ] }, { "name": "j", "size": 5 } ] } ] } How can I return two adjacent levels in Python? For example return: a - b,e f - g,j The data could become very large,

How can I get certain levels of JSON in Python?

故事扮演 提交于 2020-01-06 07:54:12
问题 If my JSON data looks like this: { "name": "root", "children": [ { "name": "a", "children": [ { "name": "b", "children": [ { "name": "c", "size": "1" }, { "name": "d", "size": "2" } ] }, { "name": "e", "size": 3 } ] }, { "name": "f", "children": [ { "name": "g", "children": [ { "name": "h", "size": "1" }, { "name": "i", "size": "2" } ] }, { "name": "j", "size": 5 } ] } ] } How can I return two adjacent levels in Python? For example return: a - b,e f - g,j The data could become very large,

How can I get certain levels of JSON in Python?

谁说我不能喝 提交于 2020-01-06 07:54:06
问题 If my JSON data looks like this: { "name": "root", "children": [ { "name": "a", "children": [ { "name": "b", "children": [ { "name": "c", "size": "1" }, { "name": "d", "size": "2" } ] }, { "name": "e", "size": 3 } ] }, { "name": "f", "children": [ { "name": "g", "children": [ { "name": "h", "size": "1" }, { "name": "i", "size": "2" } ] }, { "name": "j", "size": 5 } ] } ] } How can I return two adjacent levels in Python? For example return: a - b,e f - g,j The data could become very large,

Part Database - Network Model / Hierachal Model / Nested Sets / Acyclic Graphs. Which is right here?

扶醉桌前 提交于 2020-01-05 15:36:11
问题 We are using PHP / SQL to build a parts database which will output as a tree structure. After plunging head first into the coding with the nested sets model we realised that we needed to adjust the model to allow for multiple parents. Effectively, every child can have more than one parent, and every parent can have more than one child, but each node cannot be its own relative. We want to link a collection of parts (A) to a parent part and create a larger part (B) whilst keeping the original

Hierarchic structure Firestore and subcollections

喜你入骨 提交于 2020-01-05 04:18:22
问题 I am trying to build a database with Cloud Firestore and having read the documentation about hierarchic structure I have found another solution to the one present in the documentation example. I have a collection of categories, and each category can have subcategories. Whereas I could use the system provided in the Firestore documentation example such as collection/document/subcollection/document... I have found another example for MongoDB where instead of having subcollections it uses nested

Javascript convert array of objects to tree

一曲冷凌霜 提交于 2020-01-04 05:27:08
问题 I am trying to convert this structure: var initial = [ { Phase: "Phase 1", Step: "Step 1", Task: "Task 1", Value: "5" }, { Phase: "Phase 1", Step: "Step 1", Task: "Task 2", Value: "10" }, { Phase: "Phase 1", Step: "Step 2", Task: "Task 1", Value: "15" }, { Phase: "Phase 1", Step: "Step 2", Task: "Task 2", Value: "20" }, { Phase: "Phase 2", Step: "Step 1", Task: "Task 1", Value: "25" }, { Phase: "Phase 2", Step: "Step 1", Task: "Task 2", Value: "30" }, { Phase: "Phase 2", Step: "Step 2", Task:

Joining two Hierarchical queries to form larger Hierarchy

我们两清 提交于 2020-01-03 16:52:06
问题 I have researched this and know I'm not the first to ask but I can't seem to get my head around it. I have created a simple example that I think will help me crack it if someone can provide the missing link! I have a table of areas that contains continents and countries in a hierarchy. I also have a table of places that contains cities and landmarks in a hierarchy. This table contains an area id column to join to the areas table. create table areas ( id NUMBER not null, name VARCHAR2(200) not

SELECT with query variables not using INDEXes

谁说我不能喝 提交于 2020-01-03 09:11:30
问题 I was playing around (out of interest) with retrieving a tree of nodes in a simple adjacency list with a recursive query using local variables. The solution i have so far is fun but i wonder (and this is my only question) why MySQL refuses to use any INDEX to optimize this query. Shouldn't MySQL be able to lookup the nearest child(s) by using an INDEX ? I'm curious why MySQL doesn't. Even when i use FORCE INDEX the execution plan doesn't change. This is the query so far, with 5 being the ID

Linq: rebuild hierarchical data from the flattened list

末鹿安然 提交于 2020-01-03 01:23:06
问题 Disclaimer: I've been fighting against this problem since 2 days (I've read a lot of similar questions on SO).. so be patient, I'm missing something about the Group By with Linq and asking for help. The Class Structure Populating the sample data I have a list of Macrotab . Each Macrotab object contains a list of Tab . Each Tab object inside with Slot inside. List<MacroTab> hierarchaldata = CreateHierarchaldata(); *For keeping the question easy to read I've moved the CreateHierarchaldata,

Recursively search for parent child combinations and build tree in python and XML

半城伤御伤魂 提交于 2020-01-01 04:23:08
问题 I am trying to traverse this XML data full of parent->child relationships and need a way to build a tree. Any help will be really appreciated. Also, in this case, is it better to have attributes or nodes for the parent-->child relationship? <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <nodes> <node name="Car" child="Engine"/> <node name="Car" child="Wheel"/> <node name="Engine" child="Piston"/> <node name="Engine" child="Carb"/> <node name="Carb" child="Bolt"/> <node name="Spare