Skip to first unread message

Pal Csanyi

unread,
Apr 6, 2018, 11:57:20 AM4/6/18
to MIT App Inventor Forum
Hi,

when I SELECT from my SQLite database name values and set these values into a ListPicker as it's elements, then I get quoted names, like on my first attached image.
I do this with the blocks as in my second attached image.
I tried to get rid of these quotes by using the 'replace all text / segment / replacement' but do not know where to put it?
How can I get rid of these quotes?

Pal
QuotedItemsInListPicker.png
AI2.png

Taifun

unread,
Apr 6, 2018, 2:10:47 PM4/6/18
to MIT App Inventor Forum
you might want to use the replace all block to replace " by empty string
Taifun

Pal Csanyi

unread,
Apr 6, 2018, 2:23:59 PM4/6/18
to MIT App Inventor Forum
you might want to use the replace all block to replace " by empty string
I did so but it not solve the problem.
I tried this like this:
1. I add the replace all block
2. I build the app - save .apk to my computer
3. move the .apk file to my phone
4. install it
5. run the app

The quoted names still remain in the app.
See the blocks on attached image.
AI2.png

Taifun

unread,
Apr 6, 2018, 4:46:54 PM4/6/18
to MIT App Inventor Forum
first split, then replace
Taifun


Chris Ward

unread,
Apr 6, 2018, 5:24:04 PM4/6/18
to MIT App Inventor Forum
Hi Taifun, didn't you mean first replace and then split?

Pal Csanyi

unread,
Apr 6, 2018, 9:46:59 PM4/6/18
to MIT App Inventor Forum
first split, then replace
I tried that, but the 'replace all text' block and all other connected blocks to it can't be connected to the 'set Beiratkozottak.Elements to' block.
See on my attached image.
Why can't be connected the 'raplace all text' block to the ListPicker's 'set Beiratkozottak.Elements to' block?
AI2.png

Chris Ward

unread,
Apr 7, 2018, 4:11:06 AM4/7/18
to MIT App Inventor Forum
Hi Pal

There is possibly something unexpected in the data format. Put together a tiny app that just reads-in the data and writes it to a file, no processing of any kind other than that. We then have something to study.

Pal Csanyi

unread,
Apr 7, 2018, 9:35:00 AM4/7/18
to MIT App Inventor Forum
Hi Chris

I just finished the tiny app in AI2.
I installed it to my phone and it works.
It uses an SQLite database:
CREATE TABLE Enrollment (
id INT PRIMARY KEY UNIQUE ,
StudentsName text NOT NULL ,
Grade INT NOT NULL ,
ClassName text NOT NULL
);
INSERT INTO Enrollment VALUES(NULL,'Georg Evans',5,'a');
INSERT INTO Enrollment VALUES(NULL,'David Brown',5,'a');
INSERT INTO Enrollment VALUES(NULL,'Bill Cox',5,'a');
Block of this app is in the attached image here.
The UI is on the second attached image here.

Did you mean this application?
Blocks_07.04.2018.15.29.png
UI_01.png

Chris Ward

unread,
Apr 7, 2018, 9:49:10 AM4/7/18
to MIT App Inventor Forum
Hi Pal

Nearly.

  • Processing - don't split the text at newlines.
  • Save the data to a plain text file so that we can see exactly what is being received.
  • Use the same data as before! 

Pal Csanyi

unread,
Apr 7, 2018, 10:39:12 AM4/7/18
to MIT App Inventor Forum
  • Processing - don't split the text at newlines.
  • Save the data to a plain text file so that we can see exactly what is being received.
  • Use the same data as before!
I changed the App like on my attached images.
Tally?
Blocks_07.04.2018.16.27.png
Designer_07.04.2018.16.29.png

Chris Ward

unread,
Apr 7, 2018, 1:00:25 PM4/7/18
to mitappinv...@googlegroups.com
Hi Pal

Add the text file to this post.

Edit - nope, your blocks make no sense: Read txt file - Set text in Label - Read label - Append to same text file?

We want to get data from the original db as you did originally but without trying to remove quotes or split at line endings, save that to a text file directly - that's it.

Pal Csanyi

unread,
Apr 7, 2018, 1:14:34 PM4/7/18
to MIT App Inventor Forum
Hi Chris

I attached here the File.txt file.
File.txt

Chris Ward

unread,
Apr 7, 2018, 3:24:53 PM4/7/18
to MIT App Inventor Forum
Hi Pal

So, raw db result has no quotes or line endings?

The text file content: Robert RedfordRobert Redford Bill Cox

I was expecting to see something like:

Bagi Patrik
Basa Enikő
Bicskei Bence
Bosznai Támas
Bús Denisz
Gorac Lora
Horvát Dávid

Try this: Instead of:

Alternative method:




Pal Csanyi

unread,
Apr 7, 2018, 3:41:20 PM4/7/18
to MIT App Inventor Forum
HiChris
Sorry, I misunderstanded you.
I made a new application instead of saving the current application with a new name, so I can modify it after.
I am going now to save my problematic project under a different name.
Then I am going to modify it to be as simple as possible.

Pal Csanyi

unread,
Apr 7, 2018, 4:12:19 PM4/7/18
to MIT App Inventor Forum
H iChris


2018. április 7., szombat 21:24:53 UTC+2 időpontban Chris Ward a következőt írta:
What I did is this.
I save my project as under different name.
Then I leave it as is, but try out the two method you adviced.
None of them works, because I get always the followings:
(Note the trailing space!)

"Bagi Patrik "
"Basa Enikő "
"Bicskei Bence "
etc.

so I can say that that both method gives the same result: the quoted names of students.

Chris Ward

unread,
Apr 7, 2018, 5:28:53 PM4/7/18
to MIT App Inventor Forum
Hi Pal

You can eliminate the trailing spaces when the data is input.

It is strange that the quotes are there, but it would seem to be done at the moment the ListView is fed with the data? 

I know that is not the case if the data is held in an AI list, then the ListView built from that, so perhaps the work-around would be:

db --> AI List --> AI ListView


Chris Ward

unread,
Apr 7, 2018, 5:34:07 PM4/7/18
to MIT App Inventor Forum
Hi Pal

If my last suggestion doesn't work (i.e. you still get quotes around the names) then perhaps the reason for the quotes is the space between Family name and Given Name. To test that, use a replace all text block to replace the test with _ (Underscore) so the records would be like this:

Bagi_Patrik
Basa_Enikő
Bicskei_Bence
Bosznai_Támas
Bús_Denisz
Gorac_Lora
Horvát_Dávid

Taifun

unread,
Apr 7, 2018, 5:38:04 PM4/7/18
to MIT App Inventor Forum
the question is, where do the double quotes come from...
Pal, can you try another Do it result of the split block?


when I try it using some simple strings everything works fine... it might be the special characters you are using, which result in the unwanted double quotes?


Taifun

Pal Csanyi

unread,
Apr 7, 2018, 6:12:39 PM4/7/18
to MIT App Inventor Forum
Pal, can you try another Do it result of the split block?
Taifun, here it is in the attached image.
AI2.png

Pal Csanyi

unread,
Apr 7, 2018, 6:17:29 PM4/7/18
to mitappinv...@googlegroups.com
To test that, use a replace all text block to replace the test with _ (Underscore) so the records would be like this:

Bagi_Patrik
Basa_Enikő
Bicskei_Bence
Bosznai_Támas
Bús_Denisz
Gorac_Lora
Horvát_Dávid
I did it. See it in my attached image.
But get this in my installed app on my phone:
"Bagi_Patrik "
"Basa_Enikő "
etc.
AI2.png

Pal Csanyi

unread,
Apr 7, 2018, 6:35:01 PM4/7/18
to MIT App Inventor Forum
I know that is not the case if the data is held in an AI list, then the ListView built from that, so perhaps the work-around would be:

db --> AI List --> AI ListView
I tried this too, but with no success.
See my attached image for Do It result.
But I installed this .apk file on my phone too, and the double quotes still remain out there.
AI2.png

Pal Csanyi

unread,
Apr 7, 2018, 6:46:06 PM4/7/18
to MIT App Inventor Forum
it might be the special characters you are using, which result in the unwanted double quotes?
No, because I just tried this out too.
I just changed the student names to contain just English characters.
I upload the modified database, build the .apk, install it to my phone, and run.
I get the names double quoted again, like this:
"Bagi Patrik "
"Basa Eniko "
"Bicskei Bence "
"Bosznai Tamas "
"Bus Denisz "
etc.

Chris Ward

unread,
Apr 7, 2018, 7:02:22 PM4/7/18
to MIT App Inventor Forum
Pal, Taifun

Have we discovered an nb166 ListView bug? Seems like it to me because we have eliminated any possible quirk in the data.

Chris Ward

unread,
Apr 7, 2018, 7:21:08 PM4/7/18
to MIT App Inventor Forum
Erm, no we haven't :)

Try this very simple file attached (ListViewFromList) that has character accents and the space between Given Name and Family Name. It is absolutely fine.
ListViewFromList.aia

TimAI2

unread,
Apr 7, 2018, 7:36:57 PM4/7/18
to MIT App Inventor Forum
What happens if you generate your list in a different way (also to view output in a label)


I don't have the sqllite extension, nor your data ;)


Chris Ward

unread,
Apr 7, 2018, 7:58:33 PM4/7/18
to MIT App Inventor Forum
Hi Tim

We already tried that :)

Chris Ward

unread,
Apr 7, 2018, 8:09:24 PM4/7/18
to mitappinv...@googlegroups.com
Hi again

So, thinking out loud and probably thinking garbage because it is late here - is it possible that the db is applying the quotes, but they are are not the characters (UTF-8 decimal 34) recognised by the AI Text Blocks, yet do get recognised by the ListView component? They could be decimals 8220 (left double quotes) and 8221 (right double quotes).

Try the attached project file ListViewFromList2.aia

If you click on button "Remove 34", which is what we are doing with the data from the db, the list is displayed but the quotes are still there.
Now click on button "Remove 8220/8221". The list is displayed with the quotes removed.




ListViewFromList2.aia

Taifun

unread,
Apr 7, 2018, 9:01:58 PM4/7/18
to MIT App Inventor Forum
Pal, can you try another Do it result of the split block?
Taifun, here it is in the attached image. 

the Do it result of the split block looks fine, there are no double quotes inside...
very strange...
Taifun

Chris Ward

unread,
Apr 7, 2018, 9:12:15 PM4/7/18
to MIT App Inventor Forum
...that might be because the font used for Do It does not support the wider range of UTF-8

Pal Csanyi

unread,
Apr 8, 2018, 2:48:28 AM4/8/18
to MIT App Inventor Forum
I think I was not clear at the beginning of my thread.
I am using a ListPicker and not a ListView in my app.
So the 'Beiratkozottak' is a ListPicker and not a ListView.

First, I set the elements of Beiratkozottak ListPicker from the database.
Second, I set the text of Beiratkozottak ListPicker from the Beiratkozottak ListPicker elements.

Sorry to forgot to mention this second setup. Mea culpa.
See my attached image of these two block modules.

AI2.png

Pal Csanyi

unread,
Apr 8, 2018, 3:02:40 AM4/8/18
to mitappinv...@googlegroups.com
So I solve the problem like this on my attached image.
Again, I am very sorry to disturb you all with this.
And thank you very much for all of you!
AI2.png

Chris Ward

unread,
Apr 8, 2018, 5:31:13 AM4/8/18
to MIT App Inventor Forum
Hi Pal

ListView and ListPicker are essentially variations of the same thing, no harm done there.

So, your final solution works, that's all that matters really :) I'm curious though, because you seem to be doing things in reverse - taking strings from a Pick list and setting a Label Component..............

I notice you have added a trim, nothing wrong with that but I would add a trim to the db input process - it's always best to ensure that your data is as squeaky clean as possible.

In the future, when naming components, make sure they identify component type as well as purpose. In my projects I also append the Screen number, making every component name unique.


Pal Csanyi

unread,
Apr 8, 2018, 6:14:56 AM4/8/18
to MIT App Inventor Forum
ListView and ListPicker are essentially variations of the same thing, no harm done there.
 OK then. Thank you for explanation.

I'm curious though, because you seem to be doing things in reverse - taking strings from a Pick list and setting a Label Component..............



I notice you have added a trim, nothing wrong with that but I would add a trim to the db input process - it's always best to ensure that your data is as squeaky clean as possible.
I put now a trim block before 'call TaifunSqlite1.Execute sql' block like on my attached image. Did you mean this? Is it right?


In the future, when naming components, make sure they identify component type as well as purpose. In my projects I also append the Screen number, making every component name unique.

Thank you very much for this advice! I will follow it in the future.
AI2.png

Chris Ward

unread,
Apr 8, 2018, 6:31:12 AM4/8/18
to MIT App Inventor Forum
Hi Pal

Did you mean this?

No, what I mean is, when the student data is entered into the database, that's where mistakes are made. The trailing space example is trivial, but it does indicate that the methods used for database input need to be more strict, else the data will be less useful - for example, the same student could be entered in the db more than once if the spelling of his/her name is slightly different each time, or there are discrepancies in other data collected. That's what we mean when we say input must be "squeaky clean" - there should be no room for errors.


Pal Csanyi

unread,
Apr 8, 2018, 6:47:38 AM4/8/18
to MIT App Inventor Forum
Hi Chris
I understand.
I am just mention it, I entered into database student names from a csv file, but not in my app.
I created a Bash shell script with SQLite statements and in that script I import datas into tables from four csv files.
When the database is created, I uploaded it to AI2.
I do not know where could be added a trailing space to the student names, like in the following example?
"Bagi Patrik "
The csv file is like this:
..
164,Bagi Patrik,8,c
..
The Beiratkozottak table in the database is:
CREATE TABLE Beiratkozottak ( az INTEGER PRIMARY KEY UNIQUE, TanuloNeve TEXT NOT NULL, EvFolyam INTEGER
NOT NULL, Tagozat TEXT NOT NULL
);

and an INSERT statement for Bagi Patrik is like this:
INSERT INTO Beiratkozottak VALUES(164,'Bagi Patrik',8,'c');

So where am I make the mistake? Where was added the trailing space to a student name?
 

Chris Ward

unread,
Apr 8, 2018, 7:20:31 AM4/8/18
to MIT App Inventor Forum
..... it is right at the front end, where either the student or someone else types-in the information. That is where to put safeguarding to ensure nothing "wrong" slips into the db. 

Pal Csanyi

unread,
Apr 8, 2018, 8:03:43 AM4/8/18
to MIT App Inventor Forum
2018. április 8., vasárnap 13:20:31 UTC+2 időpontban Chris Ward a következőt írta:
..... it is right at the front end, where either the student or someone else types-in the information. That is where to put safeguarding to ensure nothing "wrong" slips into the db. 
In my case there is no trailing space out there, neither in the LibreOffice Calc, nor in the .csv files.

Chris Ward

unread,
Apr 8, 2018, 4:32:57 PM4/8/18
to MIT App Inventor Forum
Hi Pal

They are there, you can see them  -eventually. They are possibly "hidden" characters and much depends on what you have as to whether you can see them.

....confused?  Ok, a simple example would be the line ending character - you can't see it unless the data is read into a text editor that can display it using a symbol character, typically a Pilcrow Sign: "¶".  

So, Format (ASCII, UTF-8, Unicode etc) and Font - very important. Let's say you have a UTF-8 file in Mandarin Chinese. You wont be able to see the intended characters unless the font you use supports them and the software you use supports both the Format and the Font. 

In my case there is no trailing space out there, neither in the LibreOffice Calc, nor in the .csv files.

So now you know that what you see is not necessarily what you have!  Here is a list of "white space " characters that you may or may not be able to see:

U+0009  character tabulation
U+000A  line feed
U+000B  line tabulation
U+000C  form feed
U+000D  carriage return
U+0020  space
U+0085  next line
U+00A0  no-break space
U+1680  ogham space mark
U+180E  mongolian vowel separator
U+2000  en quad
U+2001  em quad
U+2002  en space
U+2003  em space
U+2004  three-per-em space
U+2005  four-per-em space
U+2006  six-per-em space
U+2007  figure space
U+2008  punctuation space
U+2009  thin space
U+200A  hair space
U+200B  zero width space
U+200C  zero width non-joiner
U+200D  zero width joiner
U+2028  line separator
U+2029  paragraph separator
U+202F  narrow no-break space
U+205F  medium mathematical space
U+2060  word joiner
U+3000  ideographic space
U+FEFF  zero width non-breaking space


Pal Csanyi

unread,
Apr 8, 2018, 6:49:55 PM4/8/18
to MIT App Inventor Forum
Hi Chris
 Thank you very much for explanation.
Now I know that that there is a trailing character just do not know where was it created?
I used LibreOffice Calc to create sheet of data.
Then I exported these datas into .csv file.
Then I import this .csv file into sqlite database by using the sqlite3 cli.
Where could I made a mistake? How to find the error?

Taifun

unread,
Apr 8, 2018, 7:44:48 PM4/8/18
to MIT App Inventor Forum
what about preparing the database using a tool like the SQLite Manager extension available for the Firefox Browser and import the database on first run of the app using the Import method?

Taifun

Chris Ward

unread,
Apr 8, 2018, 10:11:06 PM4/8/18
to MIT App Inventor Forum
Hi Pal

That is a very long-winded way of creating the data. Taifun's suggestion is well worth considering.

Concerning LibreOffice Calc, that could be where the trailing spaces com from. I have great respect for LibreOffice but it would not be my choice for this task.

Do you know any other programing languages? Most will have enough for you to DIY a custom (desktop) interface with a database.

Pal Csanyi

unread,
Apr 9, 2018, 12:23:08 AM4/9/18
to MIT App Inventor Forum
Hi Taifun,


2018. április 9., hétfő 1:44:48 UTC+2 időpontban Taifun a következőt írta:
what about preparing the database using a tool like the SQLite Manager extension available for the Firefox Browser and import the database on first run of the app using the Import method?

Taifun
 
One can read about this Firefox extension
This extension depended upon the interface to sqlite engine embedded in Firefox. As the interface has been removed in Firefox 57, this extension no longer functions.
here:
https://addons.mozilla.org/hu/firefox/addon/sqlite-manager/

So this extension no longer functions.

Pal Csanyi

unread,
Apr 9, 2018, 12:29:07 AM4/9/18
to MIT App Inventor Forum
Hi Chris
I understand.
No, I do not know any other programming languages.
But I have installed SQLite Studio, SQLiteman and DB Browser for SQLite here, on my system.

Taifun

unread,
Apr 9, 2018, 10:09:45 AM4/9/18
to MIT App Inventor Forum
One can read about this Firefox extension
This extension depended upon the interface to sqlite engine embedded in Firefox. As the interface has been removed in Firefox 57, this extension no longer functions.
here:
https://addons.mozilla.org/hu/firefox/addon/sqlite-manager/
So this extension no longer functions.

there are most probably also other tools available to prepare a sqlite database... you might want to do a Google search... let us know, what you find out
Taifun
Reply all
Reply to author
Forward
0 new messages