How do I handle errors for "list from csv table"?

I import csv table from text (got from file).
My test data has the following error : " is not escaped in one of the data rows (e.g. it is ...,"Jan "Zap" Novak" while it should be ,"Jan ""Zap"" Novak".
My app just throws error (screens from Phone and PC while debugging in Companion):

The screen.OnError does not catch it.
What can I do (before writing my version of list from csv table)?
(I've not attached blocks as it is single block stated in title)

You do not appear to be using a valid csv format for your data.

Nick, Dave,Jane

Thanks for prompt reply.
Yes, you are right - my problem is that this function should handle error gracefully, not blow-up application. I'm looking for one the following options:

  1. If it returns lists, it may return empty list.
  2. If it throws error, this error should be catch'eable.
  3. Or there should be another function like "is this a proper csv table"

But I can't find any of these.
BTW : this was intended to be single Column "Jan ""Zap"" Novak" but generating it did not escape (make 2 of each) quotes. But it does not matter - as you said it is malformated anyway so function should handle error gracefully.

1 Like

Until I find a proper fix I've applied the following workaround:

  1. split text (file) by lines (1st is the header, other are rows)
  2. each line split into lists of tokens (matches) using this regex :
  3. check if tokens in each line are equal (u can assume rest of line is empty but I prefer to demand all fields and last one non-empty)

Above regex GetMatches of cn.kevinkun.KevinkunRegEx.aix properly parses this test line:
123,,"123", John, "John", "John ""Zap"" Novak", "sometimes, not always"
On error it simply finds less matched than expected (e.g. zero) or lines parse to lists of distinct length.

But it is much longer than just invoking list from csv table so if no easy solution is found a bug should be logged against this function IMHO.

The issue is with the data you are using, not the block, which is quite specific:

list from csv table

As you have shown by fixing the data, the block will work. The block expects correctly formatted csv data, if you do not feed it as such, you will get the error. However, it might be better to have an error block that handles the error, as opposed to an unrecoverable runtime error.

Exactly: functions intended to process input data must not assume correct data - they must gracefully handle errors.
Thanks a lot and best regards