List from list Creation error Cannot parse text argument to "list from csv table" as a CSV-formatted table

I am importing a CSV file into a list. It works on the first time I import the whole CSV as a list, but when I attempt to make a second list from the values returned I get the error Cannot parse text argument to "list from csv table" as a CSV-formatted table.

For reference here is the data output. The colored scribble area is the raw file after making a list from the whole csv. The top output is the data returned when accessing the first indexed item in the list.
I need to be able to take this indexed data and create a new list so that I can access each item by index... Or perhaps there's a better way?

PerLineData is a list

It does not make sense to use the list from csv table block for lists, only for csv tables...

This is PerLineData... it is already the list you are looking for

Taifun

I am not following. The indexed output returns another list of data from which I need access to individual data.

Each indexed line from the CSV is returned in a list as a single result containing the comma-separated data.

How do I index or otherwise access each data value? The first data set returned from indexed 1 is actually the headers/labels for the data. Can a dictionary be created from this CSV file?

Can you upload the unprocessed file here?

I think your file lacks \n end of line markers ,
because your list representations in JSON do not have the nested [] inside [] that a true table (list of lists) would have.

Here is the raw data. Each line is a separate set of data. The first line contains the headers.
TrussData.csv (29.9 KB)

Okay, I stand corrected.
Your initial csv to table conversion should have returned a list of lists, with item 1 being the header row.

However, once you have the table (list of lists) from that CSV text (and CSV means Comma Separated Values TEXT), you should never try to repeat that conversion on the table or its rows.

Read the intro articles in the prior posts.
8cdbee340ea85e01ab0b135534cc742226911c6b_2_690x266

Which column would you want as the key? It must be unique.


This first column

I probably have a table to dictionary converter in stock, but it might be quicker to just code it again than to search for it.



table_to_dict.aia (8.2 KB)

P.S. These blocks can be dragged directly into your Blocks Editor workspace.

Dragging blocks

P.S. This returns a dictionary of dictionaries.

It did not drag over, but I was able to load the file. THANK YOU for you so very much for your time and assistance! :pray:

Now that the data is in the dictionary I can load the data by key? How do I get individual items out and into a variable?

If for example, I wanted to get "snow load" from the key " 22 Foot 4in12". Can I access it by indexing the 8'th value or is there a better way to gain the one specific data value? I'm back to the original problem of accessing the specific values within the returned "list".

The better way is to get by header key from dictionary found under board key.FAQ Section: JSON and Dictionaries


I see that I get a list of items when calling the data from the key. I get the entire row back.

data

How do I extract one single data item from the returned data? I still get the error if I try to use a list function,


I was able to access the data by using a select list item block and a simplified dictionary output

The choice of how to get to row items is yours. I hate to have to remember column numbers.

P.S. rename that procedure to be more appropriate. Unfortunately, the backpack still trashes procedure names.

How would get row items by name?

For dictionary lovers:


sample run 2
table_to_dict (1).aia (8.9 KB)

Thank you so much. Really! I have been tinkering with this all day

I polished it up a little to avoid wrong answers if changing the row while keeping the column.



table_to_dict (2).aia (9.0 KB)
sample run 3

I was just thinking about that. Thanks.
Now I get how it is done to access the data. :floppy_disk: It was just was not clicking for me. Even from everyting I read.

It seems obvious now :crazy_face:

1 Like