Search Index, ID, Name

299 views
Skip to first unread message

Chris Stanlley

unread,
Oct 10, 2019, 2:17:00 PM10/10/19
to MIT App Inventor Forum
Hello,

Please help me split the variables Index, Id and Name which is in csv into 3 separate parts. 
1.Index
2.Id
3.Name

Thank  you.


search.csv
blocks.png

SteveJG

unread,
Oct 10, 2019, 2:24:59 PM10/10/19
to MIT App Inventor Forum
instead of the split block at \n , perhaps  split at ;  ????

Chris Stanlley

unread,
Oct 10, 2019, 2:37:58 PM10/10/19
to MIT App Inventor Forum
Sorry, I didn't understand.

SteveJG

unread,
Oct 10, 2019, 2:40:05 PM10/10/19
to MIT App Inventor Forum
Your csv looks like this Chris 

Index;Id;name
1;1104;Jhon
2;1001;Gard
3;1000;chris
4;2224;Stanlly
5;1106;Hani
6;16001;jaafer
7;551000;Doorm
8;2224;Hhosch

...so it is not a 'true' comma separated value file.  The separator is a semi-colon  (    ;   )


Chris Stanlley

unread,
Oct 10, 2019, 2:43:51 PM10/10/19
to MIT App Inventor Forum
I replaced it into comma, but it's the same

Taifun

unread,
Oct 10, 2019, 3:02:06 PM10/10/19
to mitappinv...@googlegroups.com
 into 3 separate parts
what does that mean? into 3 separate lists?
first you should replace the semicolons by comma (precondition is, that there are no commas in your csv file) to be able to use the list from csv table block to convert your csv file into a list of lists...


Taifun

Trying to push the limits of App Inventor! SnippetsTutorials and Extensions from Pura Vida Apps by  Taifun.

Chris Stanlley

unread,
Oct 10, 2019, 3:06:27 PM10/10/19
to MIT App Inventor Forum
Hi Taifun,
Thank you so much,

I replaced the semicolumn into coma but I am still confused.
Please I need advise.


search.csv
Message has been deleted

Chris Stanlley

unread,
Oct 10, 2019, 3:11:49 PM10/10/19
to MIT App Inventor Forum
Yes, into three list. So, each list has a variable in order to  make search.

Taifun

unread,
Oct 10, 2019, 3:15:31 PM10/10/19
to MIT App Inventor Forum
the first step ist to create a list of lists of your data, my guess is, you have been able to do this, unfortunately you did not provide a screenshot of your newest blocks
then use a for each in list loop to read each row one by one and add each column into separate lists
see again the previous links to find out how to work with lists

Taifun

TimAI2

unread,
Oct 10, 2019, 3:21:00 PM10/10/19
to MIT App Inventor Forum
Some blocks

blocksSearchcsv.png


screenSearchcsv.png



SteveJG

unread,
Oct 10, 2019, 3:33:13 PM10/10/19
to MIT App Inventor Forum

listFromcsv.PNG


Chris Stanlley

unread,
Oct 10, 2019, 4:10:43 PM10/10/19
to MIT App Inventor Forum
Hi Tim,

Thank you so much for help.
I have done what you said but 
there is error saying Cannot parse text argument to "list from csv row" as CSV-formatted row
Note: You will not see another error reported for 5 seconds.

please have a look to the .aia

TimAI2

unread,
Oct 10, 2019, 4:13:50 PM10/10/19
to MIT App Inventor Forum
should be:

"list from csv table" block

:)

Chris Stanlley

unread,
Oct 10, 2019, 4:21:35 PM10/10/19
to MIT App Inventor Forum
Hi Steve,
Can I replace the initialize global myCSV to be : INDEX,ID,NAME instead of long one? 

Chris Stanlley

unread,
Oct 10, 2019, 4:34:14 PM10/10/19
to MIT App Inventor Forum
Thank you it's my mistake.
Steve also did something much better and I am waiting for answering me if initialize global myCSV can be  : INDEX,ID,NAME instead of long one.
Thank you so much Tim for help.
Good luck:)

SteveJG

unread,
Oct 10, 2019, 4:38:11 PM10/10/19
to MIT App Inventor Forum
The CSV should be in the form of a csv table       Index;Id;name \n1;1104;Jhon \n2;1001;Gard \n3;1000;chris \n4;2224;Stanlly \n5;1106;Hani \n6;16001;jaafer \n7;551000;Doorm \n8;2224;Hhosch  . 

Can you replace the variable myCSV?    Yes, as long as you replace it with a csv that is in table form.   What you do depends on where your csv originates, what form it is in etc.  If you work with a csv table, it is easy to convert the csv into a List of lists.   You can hard code the csv or import it using the File control as Tim attempted to do.    ... instead of one one ?    You need to provide a better explanation of what you hope to do.  If you create your csv using commas, you do not need to convert the semi-colons you started out with to commas so providing the csv as   INDEX,ID,NAME  works just fine.

ABG

unread,
Oct 10, 2019, 5:11:46 PM10/10/19
to MIT App Inventor Forum
See the attached for a general purpose solution, that will
filter your choice of table by your choice of column,
with your choice of test type.

The sample run captured is a lookup of the population
of the state of Alabama, chosen because it came up high in the list by name.

You can find downloadable procedures at 

ABG

Capture06.PNG
complaint.png
conversions.txt
Designer.PNG
DISTINCT.png
global Columns.png
global comparand.png
global filter_types.png
global filters.png
global results.png
global sample_files.png
Capture07.PNG
global source_data_only.png
global source_table.png
global source_text.png
global test.png
global test_value.png
load_results.png
make_Elements.png
make_object.png
multi_filter.aia
nst-est2018-alldata.csv
Capture08.PNG
passed.png
test_points.png
when btnAdd Click.png
when btnAddFilter Click.png
when btnCancel Click.png
when btnIsNot Click.png
when btnRunFilters Click.png
when FileSource GotText.png
when lpkChoices AfterPicking.png
when lpkChoices BeforePicking.png
Capture09.PNG
when lpkColumnName AfterPicking.png
when lpkColumnName BeforePicking.png
when lpkResults AfterPicking.png
when lpkSource AfterPicking.png
when lpkSource BeforePicking.png
when lpkTest BeforePicking.png
when lpkText AfterPicking.png
when lvwFilters AfterPicking.png
when ntfKeepRemove AfterChoosing.png
When Screen1 Initialize.png
Capture10.PNG
blocks.png
Capture01.PNG
Capture02.PNG
Capture03.PNG
Capture04.PNG
Capture05.PNG
Capture11.PNG
Capture12.PNG
Capture13.PNG
Capture14.PNG

ABG

unread,
Oct 10, 2019, 5:22:04 PM10/10/19
to MIT App Inventor Forum
If you can identify one column of your table as a unique index, then you might take advantage of
the lookup in pairs block for special purpose lookup by index value.

Where you go from here depends on how frequently your data changes.

ABG

ABG

unread,
Oct 10, 2019, 6:02:14 PM10/10/19
to MIT App Inventor Forum
See this project doc for a simpler single purpose app example ...

ABG

Chris Stanlley

unread,
Oct 11, 2019, 7:20:23 AM10/11/19
to MIT App Inventor Forum
Hello all,

I am sorry to make you confuse about what exactly I need.
I just need to know how to view Employee details by using Listview after putting any one of data of employee just by putting one of these :
- Employee name
- Employee Id 
- Employee Index 
For example if I put 2224, it will come two employees which has same number but the names are different so I can select one of them by using Listview then will come the result below.
I know it is something tricky.  
Please help me.

TimAI2

unread,
Oct 11, 2019, 7:48:19 AM10/11/19
to MIT App Inventor Forum
See attached aia

I have used a listpicker to provide only the ID's available in your csv

You may want to sort the ID's in the listpicker before display ?
If so, you can use an extension or follow the sort routine as provided by Sajal Dutta here
searchcsv.aia

Chris Stanlley

unread,
Oct 11, 2019, 1:41:04 PM10/11/19
to MIT App Inventor Forum
Hi Tim,

At the moment I have sorted the blocks and replaced the list picker into Listview. So, I think it's much better than the previous one and differently you understood what exactly I need. Thank you so much Tim.  

Now I need to finalize after replaced the second list picker into label text in order to put the value in viewoutput instead of list picker. So, if you can solve it for me. Thanks a lot.

ABG

unread,
Oct 11, 2019, 2:40:46 PM10/11/19
to MIT App Inventor Forum
See the attached section of code where you load global myList.

First you set it up as a table (a list of lists),
then you immediately overwrite it as a list of strings, one per row.

Then you try to select items from the strings, which are NOT LISTs.

Make up your mind.

ABG

when file1 gotText.png

TimAI2

unread,
Oct 11, 2019, 2:49:10 PM10/11/19
to MIT App Inventor Forum
That wasn't in my aia project provided ;)

Chris Stanlley

unread,
Oct 11, 2019, 3:37:03 PM10/11/19
to MIT App Inventor Forum
Sorry, it's my mistake
I have rewrite the project again. 
Please, I just need to fix the last block in order to View name after picking listviewsearch.

The Idea is when I write 1104 in txt box it shows 
 
1,1104,Jhon

Then I pick this items in order to put the third value (Jhon) in ViewOutput Text.

 
blocks (1).png

TimAI2

unread,
Oct 11, 2019, 5:38:22 PM10/11/19
to MIT App Inventor Forum
What if you have more than one name, as in your previous request as in the search.csv you provided ?

Chris Stanlley

unread,
Oct 11, 2019, 10:34:40 PM10/11/19
to MIT App Inventor Forum
It will be much difficult if I have more than one name. So, I must have only one name.

TimAI2

unread,
Oct 12, 2019, 4:39:29 AM10/12/19
to MIT App Inventor Forum
This will return the first (and only?) name from the selected ID

blocksfindone.png


Chris Stanlley

unread,
Oct 12, 2019, 4:58:21 AM10/12/19
to MIT App Inventor Forum
Not exactly. If I put Id #  it will return the first name and index

TimAI2

unread,
Oct 12, 2019, 5:03:22 AM10/12/19
to MIT App Inventor Forum
Sorry, not properly woken up ;)

blocksfindonetwo.png


Chris Stanlley

unread,
Oct 12, 2019, 5:44:19 AM10/12/19
to MIT App Inventor Forum
Hi Tim,

Thank you so much Tim.

There is a message saying The operation Elements cannot accept the arguments: , ["1,1104,jhon"]

TimAI2

unread,
Oct 12, 2019, 6:06:44 AM10/12/19