2017년 4월 2일 일요일

is in list error


I am trying to import data from a file. When I get data, I convert it to a list. then I check if the first item in the first list in a list of lists. I get that its "b15". then I check if it's already on the list,  but it says false, although it is there. I tried with and without the trim, but it doesn't work. I have to prevent duplicate entries. Any ideas?

Edit: Now I checked the length of the two "b15" and one seems to be four letters. What could be the extra letter even when I check it with trim?



--
how do the data in the file look like? can you provide an example?
currently you convert the data using the list from csv table block and assign it to variable geciciname?
unfortunately the Do it result hides most of your blocks...

-- 
Perhaps change all \n to a zero length string to filter out invisible NL characters?

-- 
Well, the data is just like this, from the csv I import:
b15,1,2013075,name1
b15,2,2013053,name2
b15,3,2014029,name3
b15,4,2014067,name4

and so on.. I convert it using the list from csv table. interestingly, it shows only the first b15 item as four digits. the others are three digits. I checked the csv file time and again, but the raw data there does not have any spaces before or after.

Is the ∖n a character? can it be removed with a block combo?

--
just update your file (to remove the strange b15) and upload it again to App Inventor
\n is a new line character, but this does not seem to be the issue here

-- 
Ok. I did this once more with some other input, and saved it as csv. Nothing looks odd in MsExcel or Notepad. But I still get duplicate entries. And the reason for that seems to be the strange character MS-DOS type command showed me. As you can see in the attached photo, there is a strange character before the class name b54. the other lines don't have this, so this is what causes the duplicate. Does anyone know what this character is? Is there a way to get rid of it? Can I build a check block to get rid of it? I'll ask my users to input csv files. If this keeps happening, I'm in trouble.


--
does this happen in Excel only or also if you create the csv file with Notepad?
you can try Notepad and save the file in UTF-8 format, see also https://puravidaapps.com/snippets.php#2webget


-- 
This looks like a three byte BOM.

It would always have the same value if it's there, 
hex EF BB BF, so test for it at the front of the file 
and chop it off if it's there.

You can generate this 3-byte sequence at run time using the
Web1.HTML_Text_Decode block and the right inputs.

Attached is a sample that generates a 2-byte BOM.
Extend it to get your 3 byte BOM.
It also shows how to see what kind of unreadable characters you have.


--
When I copy cells from excel to notepad and save it as csv there, the odd character is still there. And now I tried to create a csv just by typing in to a notepad and saving it as a csv file, it's still there.

From Stackoverflow:
In particular, Microsoft compilers and interpreters, ... will add a BOM to the start when saving text as UTF-8. 
I believe that's the whole case.  ABG, you suggest a solution which will be a new chapter for me. I have no idea how to deal with encoding decoding things. So, I'll take the shortcut. Now the easiest way for me would be to tell the users to create a line of headings for the data below, and tell the app to ignore the first item in list.

--
Sneaky!
I love it!

--

댓글 없음:

댓글 쓰기