Search Index, ID, Name

294 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
to MIT App Inventor Forum
On testing, turns out my original blocks were correct - more awake than I thought ;) -  aia project supplied
Check things at your end.....
searchcsv_revised.aia

Chris Stanlley

unread,
Oct 12, 2019, 7:35:06 AM10/12/19
to MIT App Inventor Forum
Hi Tim,

I appreciate of your work.
I tested the .aia and works fine but when I tested with a very big csv it stock for a long time then return the value. So that is why I prefer the that I have but it need to finalize it at the end.
Kindly have a look to my .aia and test it.

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

Then I pick up one items to return name and put it in label1

TimAI2

unread,
Oct 12, 2019, 7:58:41 AM10/12/19
to MIT App Inventor Forum
OK, I see the issue. With your somewhat confusing blocks you are converting the list (Index,ID,Name) output to a string
This needs to be converted BACK to a list to extract the name (or you could just do text manipulation)
See attached
Find_Id_revised.aia

Chris Stanlley

unread,
Oct 12, 2019, 8:11:25 AM10/12/19
to MIT App Inventor Forum
I see. 
Thank you so much Tim for all your effort and hard work. It works fine.
Good luck.

Chris Stanlley

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

Excuse me Tim Only one more and last question.
Suppose I need to display Id and Name in Listview I mean before picking an item in Listview Like this:
1104,Jhon


TimAI2

unread,
Oct 12, 2019, 1:02:59 PM10/12/19
to MIT App Inventor Forum
See attached
Find_Id_revised_again.aia

Chris Stanlley

unread,
Oct 12, 2019, 1:21:39 PM10/12/19
to MIT App Inventor Forum
Wonderful!

Thank you so much Tim.
You are really a helpful App developer.

Chris Stanlley

unread,
Oct 12, 2019, 1:52:15 PM10/12/19
to MIT App Inventor Forum
Hi Tim,

I am sorry to tell you that it is stock again when I tested with a big data of .csv although it works with the previous .csv in perfect way. 

TimAI2

unread,
Oct 12, 2019, 1:54:20 PM10/12/19
to mitappinv...@googlegroups.com
In what way is it stuck?
How many entries in your big data?
Is your big data a properly formed csv ?

Chris Stanlley

unread,
Oct 12, 2019, 2:27:28 PM10/12/19
to MIT App Inventor Forum
Hi Tim,
I am wonder because in your previous Find_Id_revised.aia, it was working with the big .csv without any problem and with out stock.

In what way is it stuck?
It stuck when I click search button.

How many entries in your big data?
6000 rows and 3 columns.

Is your big data a properly formed csv ?
Yes,it formed with comas and there is coma between every item.

TimAI2

unread,
Oct 12, 2019, 3:01:47 PM10/12/19
to MIT App Inventor Forum
I have tested with 1000 entries and it works OK

Can you share your "big data" ? (You can do it by private email if you wish)

TimAI2

unread,
Oct 12, 2019, 3:16:46 PM10/12/19
to MIT App Inventor Forum
Tested with 6000 entries, still works OK

Chris Stanlley

unread,
Oct 12, 2019, 3:35:37 PM10/12/19
to MIT App Inventor Forum
Hi Tim,

I think the problem is because there is space between words in each item in column one in my .csv which is needed
Because the idea is when I write a single word like abolish which is located in column one and row three in my .csv, it returns :
Abnormal abolish abolition,3

I noticed that you removed block which has procedure Matches. It might be this is the problem.


blocks (3).png
blocks (4).png

TimAI2

unread,
Oct 12, 2019, 3:44:41 PM10/12/19
to MIT App Inventor Forum
You keep changing things!!!

I worked to your remit of Index,ID, Name (a single first name) and tried to keep to your blocks where it made sense.

You will need to share your "big data" or an example of it.

If there are any more changes then now is the time to tell us !

Chris Stanlley

unread,
Oct 12, 2019, 3:47:14 PM10/12/19
to MIT App Inventor Forum
Here you are.

Thank you a lot Tim
search.csv

TimAI2

unread,
Oct 12, 2019, 4:02:03 PM10/12/19
to MIT App Inventor Forum
Do you want to return the entire contents of the "name", that is all three words ?

Your example is ordered differently Name, Index, ID. Is that how your "big data" is set out ?

Your example does not have a header row, should it have one? Does your "big data" have one ?

Are you happy with your app layout, the need to "know" and type an "Index" number, click a button to fill a listview with items that match ("Index" and "Name" only), then for a listview selection to return just "Name" ?

You need to be clear and specific about what you want....

Chris Stanlley

unread,
Oct 12, 2019, 5:35:44 PM10/12/19
to MIT App Inventor Forum
Do you want to return the entire contents of the "name", that is all three words ?
Yes


Your example is ordered differently Name, Index, ID. Is that how your "big data" is set out ?
Yes it is set as Name,Index,ID
Your example does not have a header row, should it have one? Does your "big data" have one ?
No, it hasn't a header row,It shouldn't have one

Are you happy with your app layout, the need to "know" and type an "Index" number, click a button to fill a listview with items that match ("Index" and "Name" only), then for a listview selection to return just "Name" ?
I'm happy with my app layout. It return Name and Id and Index but it view Name and Id only in ListView

TimAI2

unread,
Oct 12, 2019, 6:29:27 PM10/12/19
to mitappinv...@googlegroups.com
Given your base data in this format

abate  abbess  abbey,1,20
Abjure  ablaze  abattoir,2,21
Abnormal  abolish  abolition,3,22
Abrupt  abscond  absolve,4,23
abut  abysmal  accent,5,24
accompany  accomplice  accomplish,6,25
accrual  accrue  accuse,7,26
acquaintance  acquiesce  acre,8,27

And your layout as below:

screenNameIndexID.png

Your blocks need to be like this:


blocksNameIndexID.png


aia attached


I haven't set lists as json. I have given the listview a set height to enable the user to scroll if more than 3 or 4 entries in the list, so that they can see the output when selecting. There is no point including a progress dialog because things happen too fast for it, but you can put it back if you want....



[EDIT]  I forgot to add a trim block after Label1.Text to remove the space before the first of the three words, should look like this:


blockstrim.png







searchcsv_revised_again_2.aia

Chris Stanlley

unread,
Oct 12, 2019, 10:57:48 PM10/12/19
to MIT App Inventor Forum
Hi Tim,

I'm so sorry to take your valuable time in order to fix this project.
Thank you so much.
Actually, I need to fix the block Textbox to be select list item index 1 instead index 3 because I need to write the word instead of number of id or index

Thank you Tim

TimAI2

unread,
Oct 13, 2019, 6:14:29 AM10/13/19
to MIT App Inventor Forum
There are probably enough examples on list and text manipulation in this thread for you to work this out.

Good luck with your project.
Message has been deleted

Chris Stanlley

unread,
Oct 14, 2019, 6:49:33 AM10/14/19
to MIT App Inventor Forum
HI Tim,

I have searched about the same thread but I didn't find any the same problem
Please I need your help if you can.
Thank you
Reply all
Reply to author
Forward
0 new messages