OCRTEXT() vs comma ( , )

I noticed that every text returned by OCRTEXT always has a comma (, ) at the end of it (such as "Hello, ").

I have a column (named OCR) for receiving OCRTEXT([Photo]). I also have another column to get the text from the OCR column by putting expression in the INITIAL VALUE.

CASE 1: This expression is working fine:: UPPER([OCR]) ::returns HELLO,

CASE 2: This expression is working fine:: FIND(",", "12, ") ::returns 3

CASE 3: This expression is not working as expected:: FIND(",", [OCR]) ::returns 0 (zero) instead of 6

AppSheet does not recognize the comma in the CASE 3, why?

Regards,

0 24 1,311
24 REPLIES 24

Perhaps wrap the [OCR] with TEXT()?

FIND(",", TEXT([OCR]))

Still returns 0, any other ideas please.

If you just want to remove it:

But as to why itโ€™s not giving the expected resultโ€ฆ @Aleksi might be able to shed some light.

(PS Aleksi: Youโ€™re my go-to person when Iโ€™m not sure who to tag, I figure youโ€™d know the team better and who to tag. )

SUBSTITUTE([OCR], โ€œ,โ€, โ€œโ€) returns Hello,

Same as the original text.

Steve
Platinum 4
Platinum 4

Sounds like a bug to me. Consider contacting support@appsheet.com directly for help.

@tony Any thoughts?

tony1
New Member

@Swoopy Does your issue reproduce in this sample app? I just tried a few images and didnโ€™t see any commas. https://www.appsheet.com/samples/How-to-grab-the-text-from-an-image-using-OCR?appGuidString=e6b13b43...

2X_5_5d1a852387ef26c9e5fece8fbc0c77107115a5aa.png 2X_b_b86331cc79f9b394eb03531d4fd1f9d0cf31eb21.png

The above picture is from the OCRTEXT Demo emulator. The below is mine. There is a comma (followed by a spaceโ€ฆto be precise). This happens on both emulator view (Chrome@Windows 10) and on Android phones (at least 2 phones tested).

Note that I am using Thailand locale.

I think I have found another clue !

1.I have made copy of โ€œOCRTEXT Demoโ€.
2.I tested on my Chrome@Windows10, there is NO comma at the end of the returned text.
3.I change type to Text and locale of its data spreadsheet file to Thailand (refresh the AppSheet editor afterward). Also, the Show option is ON.
4.Repeat step 2, there is a COMMA at the end of the returned text. Additionally, there are commas added to every space between words (or rows).

The more interesting thing is that AppSheet can not deal with this additional comma { FIND(), SUBSTITUTE(), etc. are not working with the comma in this case }.

tony1
New Member

@Swoopy Very strange. Iโ€™d like to do a controlled experiment to figure out whatโ€™s wrong here. Would you please send an email to support@appsheet.com with the following information:

  • The exact image file that is showing different behavior
  • The name of the app where youโ€™re having the problems
  • Exact steps for me to recreate the problem on my end

Also, if you havenโ€™t done this already, please go to https://www.appsheet.com/account/account#_tab_acctConfig and check the option that enables support access.

app name is Smart Yard

I just simply put OCRTEXT([Photo]) in INITIAL VALUE of a column named Object (which is Key column). It is not different from the sample app.

1.It adds comma and space (, ) to every text returned by OCRTEXT.

2.This comma and space are not recognized by AppSheet. They are not respond to FIND() SUBSTITUTE() but do respond to LEN(). AppSheet knows they exist but do not know what they are (the comma).

Regards,

For more information, the OCRTEXT([Photo]) returns

anitech, ใ‚ขใƒ‹ใƒ†ใƒƒใ‚ฏ,

There are 2 commas and a space at the end in this text. But SUBSTITUTE(OCRTEXT([Photo]), โ€œ,โ€, โ€œxxxxxโ€) returns nothing (blank).

Regards,

@tony
Perhaps you remember that I reported this behavior to support@appsheet.com on 12 Nov 2019:

Just found a strange thing with OCRTEXT().
I have a TEXT column with initial value OCRTEXT() expression. When SHOW is enabled, it will create TEXT with comma separated values like:
1513.56.343, 1513.56.342, 1513.56.345, โ€ฆ
But when SHOW? is disabled, it will create LONGTEXT with newlines like:
1513.56.343
1513.56.342
1513.56.345
โ€ฆ
This is the same result as if I would change the column Type to LongText and enable SHOW.

@Swoopy Please try to disbale the SHOW? in your OCRTEXT column, or set it to FALSE.

Thanks. Also, I think I have found another clue !

1.I have made copy of โ€œOCRTEXT Demoโ€.
2.I tested on my Chrome@Windows10, there is NO comma at the end of the returned text.
3.I change type to Text and locale of its data spreadsheet file to Thailand (refresh the AppSheet editor afterward). Also, the Show option is ON.
4.Repeat step 2, there is a COMMA at the end of the returned text. Additionally, there are commas added to every space between words (or rows).

The more interesting thing is that AppSheet can not deal with this additional comma { FIND(), SUBSTITUTE(), etc. are not working with the comma in this case }.

Is this a bug or something? For sure, this is not a solution to me.

I am about to use this feature for my Key column. So, no choice but to show it.

I also see that you cannot use FIND() or SUBSTITUTE().
But you can use
INDEX(SPLIT([OCRTEXT],","),2)

When your [OCRTEXT] column gives you
anitech, ใ‚ขใƒ‹ใƒ†ใƒƒใ‚ฏ,

Then the result of the above expression will be
ใ‚ขใƒ‹ใƒ†ใƒƒใ‚ฏ

Unfortunately, SPLIT() in my app is not working like yours. There is no change at all.

anitech, ใ‚ขใƒ‹ใƒ†ใƒƒใ‚ฏ,

However, LEN() works fine to count the extra comma. This expression

LEFT(TRIM([OCR]), LEN(TRIM([OCR]))-1)

returns

anitech, ใ‚ขใƒ‹ใƒ†ใƒƒใ‚ฏ

There is no comma at the end, but the comma between 2 words is still not recognized by AppSheet.

tony1
New Member

@Swoopy Thanks, I was able to reproduce it. Seems like it has to do with the Text vs. LongText issue. I didnโ€™t have to change the sheet locale to Thialand. Let me get back to you with a fix.

tony1
New Member

So the issue is that our Text-type input fields are replacing newlines with commas. This only affects the display of the valueโ€”the underlying value itself has the original newlines. LongText types do not do this. Iโ€™ll try to figure out why thereโ€™s this behavior difference, but for now, you can use LongText.

Actually, my bad. It will save the comma to your sheet. Itโ€™s more than just a display issue.

tony1
New Member

It looks like Text columns replace newlines with spaces in most cases. Text inputs are supposed to be a short, single line of text. However, when updated from a formula, Text inputs would replace commas with spacesโ€”Iโ€™ve put in a change to make it so they replace commas with spaces to be consistent. If you want to preserve newlines from your OCRTEXT, you should use LongText.

Hi @tony. I found another โ€œbugโ€:

The OCRTEXT() Column is with Type โ€œTextโ€.
When SHOW is enabled, it produces Text without NewLines.
When SHOW is disabled, it produces LongText with NewLines.

Thanks for raising that point. Does the problem still happen if you use LongText?

If I use LongText, it creates LongText with NewLines. Thatโ€™s okay.
But in the case Iโ€™ve described, I use Text that is handeled as LongText.

Top Labels in this Space