Flummoxed by lister... halp

I’ve been working with a lister a good bit lately, and as soon as I think I’ve got a clear handle on the documentation, I suddenly find that I’m not so sure that I do. :grimacing:

@Ivan I hate to summon you directly here … but boy golly would I love a push in the right direction.

With that in mind…

Tables

I’ve got a good handle on how general tables work:

So far no questions.

Lists of Lists

Where it does get squirly for me is with python data types as inputs. Constructing a list of lists, I’m seeing the contents of my lists show up in Lister…

My list of lists looks like:


listOfLIsts = [['1', '2', '3', '4'], 
			['5', '6', '7', '8'],
			['9', '10', '11', '12']]

Where I’m flummoxed is that I would expect that each list would be a new column… but instead each new list is a new row:

I think that’s actually working as expected… it’s just confusing form a data construction point, and I’m happy to get over this mental block as long as I’m correctly understanding that each list resents a row and not a column. :slight_smile:

Dictionaries

I have no idea how this works…

Nothing I’ve tried has worked here and it’s been a real head scratcher - so any nudge would be HUGELY appreciated.

List of Python Objects

This one I also think I understand - lister receives a list of python objects, and their members can in turn be used for columns - which is super rad.

Summary

Big questions:

  • When giving lister a list of lists each lists is a row, not a column - correct?
  • When giving lister a dictionary… How on earth does this work?

Attached is a quick tox that I’ve been using to wrap my head around this.
Thanks in advance!

base-lister-what-now.tox (180.6 KB)

2 Likes

+10. Also I see Matthew’s point on the lists = rows instead of list = columns. Maybe being able to flip a switch in the lister, that’d be best to choose based on how your data is formatted and structured. I could see both being useful.

When giving lister a list of lists each lists is a row, not a column - correct?

Correct. My general design philosophy for lister was that it displays a top-down list of data objects with a row per object. So whether the object in the list is another list, a dict, or some other object, each item in the provided list will always be one row in the lister. The idea being that you can then operate on lister.Data[3] if you want to do something with the third row (assuming 0 is a header).

This parallels the common usage of DATs, with their headers on top and a data item per row. Look at an OP Find DAT to see what I mean… headers at the top, each row represents a single operator. Imagine it as a lister… you would feed it a list of operators, not a list of names then a list of types then a list of paths etc.

When giving lister a dictionary… How on earth does this work?

You are not meant to give lister just a dictionary as raw data. What you can do is give it a list of dictionaries. That works similarly to a list of objects… each column represents a key in the dictionary (where each column would be a member in the case of objects). I’ve attached a super simple example with a list of dictionaries in the Raw Data parameter.lister.tox (29.8 KB)

I see in your Dictionaries example that again you are trying to feed lister columns of data. I suspect that is what’s tripping you up the most. Lister always wants a list of rows, with each row representing a piece of similarly formatted data. I’ve considered refactoring lister to allow it to be turned on its side so that each column is a piece of data, but it is a fairly large refactor and it keeps falling down in priority. Posts in the RFE section with specific use cases would push it up if it’s important!

All that said, it is relatively easy to convert your data from column oriented to row oriented, and the onGetRawData callback is the place to do that.

(Please feel free to tag me directly any time. Notifications in the new forum are still a bit wonky for me. Also, I was just today thinking that I need to make a blog post about lister and some of its less apparent features. I’ll consider your questions here a confirmation!)

4 Likes

@Ivan - this is beyond helpful.

Thank you thank you. :pray:

Exactly the nudges I needed to get un-stuck. I was also thinking about lister blog post - which is in part where all my questions where coming from :wink: