I am using the Create CSV component from Lunchbox in a lot of a scripts used on Shapediver to create CSV data, which can then be downloaded via Shapediver.
What I have noticed is that the component doesn’t like any input to be empty or null. If any of the values are null, the whole output is null. That means adding a check and replacer to every input that could potentially be empty.
Here you can see the component outputting Null if one of the inputs is empty:
I could not reproduce this in a simple patch, so it must be a combination of things. Unfortunately the component doesn’t output any errors and turn orange or red, so it’s hard to find out what the cause of the error is, but its definitely there.
Maybe then the feature request is actually just that it turns orange and outputs an error if it doesn’t produce any output.
But I think if the component encounters an error it should really use the built-in mechanisms of showing that an error occurred in it by changing color. Also I think the component should try to show the internal error message.
Maybe it never came up before, but I think it should be best-practices for every plugin developer to follow those conventions if it is reasonable.
I would actually like to know WHY the component fails. There isn’t really a reason, since a CSV can handle empty fields just fine.
you can pretty easily reproduce the csv component with a Text Join + Flip Matrix + eventually Repeat Data and Merge if you also want to include the Header, but I think you already knew that
probably the best way to circumnavigate the issue is to get rid of Nulls ahead of the csv component by replacing those with a sort of unique placeholder text, and then replace those placeholders with empty text afterwards, something like:
because at the moment I can’t think of other things that could create problems (Nulls and NaNs are the only ones that come to my mind), I think if you are happy to replace Nulls like with the above, you might rely on that component again to do its correct job
by the way, I also agree the csv component spitting out a single null instead of turning orange/red when malfunctioning is an issue that should be looked into
Surely it would make sense to also be able to replace a single Null and not just Nulls in a list.
As for the Create CSV, it most likely does a cast to string internally and NaN does cast as literally the string “NaN”, but casting a Null usually fails. I would have thought they might have considered that possibility though, as CSV are usually used for times when you have lots of data. Having empty fields in a CSV is also pretty normal.
I would consider the not turning orange/red a bug. Being able to handle Nulls would be a nice feature.
I can’t find a Github/Bitbucket for Lunchbox, only Lunchbox ML, so I can’t create an issue or even a pull request. On food4rhino it says to write an email, so I’ll do that and link to this thread.
I got a reply from Nicole from Provingground and thought I would post it here as well:
Hi Armin,
Thanks for letting us know! You should be able to remove null values or replace null values in your dataset before using the Create CSV component. We’ll keep this in mind for future development. We appreciate your feedback!
Nicole Mater, RA
Director of Product
She sadly didn’t comment or acknowledge the actual bug, which is not showing the error. Let’s hope they will fix it.
Hi Armin,
The CSV tool hasn’t been revisited in a long time (I estimate it’s a decade old). I have a list of items that I work through as time allows so I can’t provide any timeline to when LunchBox updates are made available.
If the CSV component is giving you issues, you can always easily format CSVs using Grasshopper’s native ‘Format’ component and other text tools.
I am fully aware that some components probably haven’t been updated in a long time, probably because they didn’t need to. It’s actually a super handy component in the context of Shapediver, where you might want to export a .csv file. We are actually using the .csv output of a Shapediver model to be parsed by make.com (formerly Integromat), which is very good at parsing CSV files.
The component not being able to handle Nulls is okay, once you know about it, but the component not turning red when it has encountered an internal error is not nice, because it makes debugging quite hard. With the roundtrip to Shapediver and the Grasshopper script running remotely it’s already more complex to debug, but when you run it locally and don’t spot an obvious error it makes hunting down the culprit much harder if it doesn’t communicate the error. That’s the reason we use Grasshopper in the first place - it cuts debugging down to only logical errors. If a component breaks that paradigm by not following the same guidelines as all other components, it kind of breaks the whole workflow.
So in a future iteration, just make sure all Lunchbox components report their errors.
I actually read in a recent thread in this forum about how Rhino compute will actually report red components. In this case the CSV component wouldn’t report an error, but still produce a Null output.