Error: Cannot parse text argument to "list from csv row" as CSV-formatted row

4361 views
Skip to first unread message

Enora Nedelec

unread,
Mar 29, 2015, 6:57:52 AM3/29/15
to mitappinv...@googlegroups.com
I have created a questions.csv file from two lists: each list has 3 items, one list per row. 



After clicking the button "show_single_question_and_answer", I want to retrieve the first row of my questions.csv and to display in my label show_question, the first item of this row (which is question1) 
I have tried doing this "the simple way" but I am getting an error: Cannot parse text argument to "list from csv row" as CSV-formatted row


Somehow, if I "manually" remove the parenthesis before and after the text in the variable created with the block "select item from list at index 1" from the list created from the csv table then I don't have this error, and the first question is displayed as expected: 


Any idea why? Thanks a lot for your time! 


Taifun

unread,
Mar 29, 2015, 10:34:40 AM3/29/15
to mitappinv...@googlegroups.com
take first row is a list



therefore you have to use the select list item block to select items from that list

Taifun

Enora Nedelec

unread,
Mar 29, 2015, 11:16:07 AM3/29/15
to mitappinv...@googlegroups.com
Thanks Taifun for your help! The links you kindly proposed really help me the past days to get a better understanding of lists, but no of them actually retrieve a single item from a csv table. 

I've tried replacing, as you've suggested, the block "list from csv row" by the "select list item" block but then I don't get the first item of "take_first_row" but the full variable.
Actually, I'm confused by you're answer as I thought the variable "select list item" would be an item as it come from the block "select list item from list where index is".




Taifun

unread,
Mar 29, 2015, 12:09:17 PM3/29/15
to mitappinv...@googlegroups.com
sorry, I have overseen, that take first row is not a list in your case, strange...
however normally it should be a list...

the questions now are: 
1. how does your csv file look like?
2. and why does the list from csv table block not convert your csv table into a list of lists?
Taifun

Enora Nedelec

unread,
Mar 29, 2015, 12:22:04 PM3/29/15
to mitappinv...@googlegroups.com

Taifun

unread,
Mar 29, 2015, 12:30:55 PM3/29/15
to mitappinv...@googlegroups.com
please add your png or jpg image directly into this thread like this
Taifun


Enora Nedelec

unread,
Mar 29, 2015, 12:47:01 PM3/29/15
to mitappinv...@googlegroups.com

Sorry for that, here is the image:



Taifun

unread,
Mar 29, 2015, 1:10:24 PM3/29/15
to mitappinv...@googlegroups.com
why so complicated?

you should learn how to work with list of lists...
see the links provided earlier

also you should think about how to avoid redundancy
you don't want to use this logic for 1000 questions, do you?

or Enis' tips about redundancy http://twodogapps.com/?page_id=686

Taifun

Enora Nedelec

unread,
Mar 29, 2015, 1:18:39 PM3/29/15
to mitappinv...@googlegroups.com

Thanks for your patience with me, I also tried like that, but same result the whole row, not the first item. 


In fact I was working with questions  from an external .csv but I got this error, so to debug the error, I started from a very simplified example, and... even there I'm getting the error. For sure, I won't use this method for my final apps. 

 

Taifun

unread,
Mar 29, 2015, 1:49:43 PM3/29/15
to mitappinv...@googlegroups.com


Enora Nedelec

unread,
Mar 29, 2015, 2:21:35 PM3/29/15
to mitappinv...@googlegroups.com
I am really surprised the block "list to CSV table" does work without first formatting the lists as a csv row. I've learn to use these blocks with this tuto and here is the model of blocks I used:

So for you, this ins't the correct way of building a csv table?






Taifun

unread,
Mar 29, 2015, 3:17:39 PM3/29/15
to mitappinv...@googlegroups.com
yes, that tutorial unfortunately does not follow the recommended way to work with list of lists
a list of lists (as the names already says)  is a list, which items again are lists

that tutorial does not use list of lists, it uses a list of csv rows instead, which actually does not really make sense and makes it very difficult to extract information later again (as you have seen)
 
The correct way to work with list of lists s is described here 
How to work with Lists and Lists of lists (pdf) by appinventor.org, see page 270

Taifun

Taifun

unread,
Mar 29, 2015, 3:38:15 PM3/29/15
to mitappinv...@googlegroups.com
as you are working with question and answers, you might be interested in

Enora Nedelec

unread,
Mar 30, 2015, 5:54:37 AM3/30/15
to mitappinv...@googlegroups.com
This is a big revelation for me. I had so much troubles dealing with the CSV I have created based on this tuto. I ended up with fields surrounded by double double quotes, I had to replace them with nothing. But this left the comma separator to mix up with the commas the users will use in the txtboxes, so I had to replace the users comma with another symbol, then change comma separator into another symbol and then replace the symbol used for the users comma by commas. All thoses tricky blocks can now be happily deleted thanks to you Taifun! I can't thank you enough for your time and your patience ! 

Also thanks a lot for this multiple choice quiz, as it would come very handy when I will set up the quizzes. 




Reply all
Reply to author
Forward
0 new messages