Bottom Page

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Connecting lists for tree view
#1
Hello,
I have a list of datetime objects that will look like below
('John', datetime.datetime(1984, 8, 26), datetime.datetime(2021, 8, 26))
('Peter', datetime.datetime(2021, 8, 26), datetime.datetime(2028, 8, 26))
('Madame', datetime.datetime(2028, 8, 26), datetime.datetime(2038, 8, 26))
('Taouse', datetime.datetime(2038, 8, 26), datetime.datetime(2044, 8, 26))
('Paul', datetime.datetime(2044, 8, 26), datetime.datetime(2054, 8, 26))
Basically a name, from date, to date. For each name interval, i divide them with a certain value and will get another list like below,
('JohnPart1', datetime.datetime(1984, 8, 26), datetime.datetime(1997, 1, 22))
('JohnPart2', datetime.datetime(1997, 1, 22), datetime.datetime(2008, 1, 19))
('JohnPart3', datetime.datetime(2008, 1, 19), datetime.datetime(2020, 11, 19))
('JohnPart4', datetime.datetime(2020, 11, 19), datetime.datetime(2021, 9, 26))
i.e John has a interval from 1984 to 2021 and i have divided that into sub periods, like this i have done for other names as well and for each name there will be 4 parts, so my sub period list will have 20 values in them, i want to display them in a tree view , i would like to know how can i connect the main list with corresponding sub period list, any help will be appreciated
Quote
#2
There's lots of ways you could do it. If you want them in order, probably two item tuples would be best:

(('John', datetime.datetime(1984, 8, 26), datetime.datetime(2021, 8, 26)),
    (('JohnPart1', datetime.datetime(1984, 8, 26), datetime.datetime(1997, 1, 22)),
    ('JohnPart2', datetime.datetime(1997, 1, 22), datetime.datetime(2008, 1, 19)),
    ('JohnPart3', datetime.datetime(2008, 1, 19), datetime.datetime(2020, 11, 19)),
    ('JohnPart4', datetime.datetime(2020, 11, 19), datetime.datetime(2021, 9, 26))))
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#3
would you mind sharing few code samples for it
Quote
#4
What do you mean, code samples for it? That's the code sample for combining the item with the list of partial items.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#5
How can i create a tuple like this from list
Quote
#6
We're not big on writing code for people here. We are big on helping people fix their code. If you give it a try, I can help you with any problems you run into.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to draw a tree in garphviz mandana 2 173 May-01-2019, 08:23 PM
Last Post: mandana
  AssertionError: View function mapping is overwriting an existing endpoint function Zhavi221 7 693 Apr-17-2019, 01:07 PM
Last Post: Zhavi221
  adding lists to lists? ivinjjunior 5 314 Apr-15-2019, 07:41 PM
Last Post: ivinjjunior
  Implementing a recursive algorithm for tree. Negativ3 3 409 Apr-10-2019, 10:43 PM
Last Post: Yoriz
  Binary tree from a list dan789 14 515 Mar-31-2019, 09:08 PM
Last Post: dan789
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 216 Mar-20-2019, 08:01 PM
Last Post: stillsen
  Better Tree Height Function Clunk_Head 2 232 Feb-24-2019, 09:15 PM
Last Post: Clunk_Head
  Call functions recursively in tree structure using python dubru 1 198 Feb-15-2019, 06:43 PM
Last Post: nilamo
  Hanging in View method learn_python 0 185 Feb-15-2019, 04:57 AM
Last Post: learn_python
  Segmentation fault when connecting to modbus device with Libmodbus alice 0 272 Dec-18-2018, 04:03 PM
Last Post: alice

Forum Jump:


Users browsing this thread: 1 Guest(s)