Bug 93973 - Inconsistent treatment of array formulas if imported, inserted or entered as text using the curly brackets
Summary: Inconsistent treatment of array formulas if imported, inserted or entered as ...
Status: CLOSED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.6.5.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: CSV-Import
  Show dependency treegraph
 
Reported: 2015-09-06 17:06 UTC by rstill74
Modified: 2023-08-27 22:14 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample CSV with SUMPRODUCT() instead brackets. (78 bytes, text/x-comma-separated-values)
2016-03-20 22:58 UTC, m_a_riosv
Details
The archive mentioned in my Comment#10; Demonstration of the claims (30.80 KB, application/zip)
2016-10-10 13:27 UTC, Wolfgang Jäger
Details
Example with directly entered text looking like array formula (16.15 KB, application/vnd.oasis.opendocument.spreadsheet)
2019-10-26 09:30 UTC, Wolfgang Jäger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rstill74 2015-09-06 17:06:10 UTC
when importing a CSV file with an array formula, the array formula becomes something between a formula and text.

discussed here: http://en.libreofficeforum.org/node/11459
(Thanks to Lupp for his help)

sample csv file:


"{=MATCH(1;ISERROR(A3:A8);0)}"
title
1
2
3
4
"=a3+a6"
"=1+a2"

now import into calc. On the import dialog screen, I am selecting:
separated by: coma, 
Text delimiter: double quote, 
from line: 1,
character set: unicode (UTF 8 )   this is default
language: Default- English (Canada)   this is my default,
all other check boxes blank.

after import I see

 
{=MATCH(1;ISERROR(A3:A8);0)}
title
1
2
3
4
5
#VALUE

however if you click on cell A1 "The curly brackets vanished in the formula bar and ... [t]he referenced range got emphasised with a coloured frame" (quoting the above mentioned thread, because they put it better than me)
This suggests It is recognized as a formula, but the formula text is displayed is displayed, not the expected number 6. if you click in the input line and change the formula (for example, hit the space bar, then the backspace key) then hit ctrl+shift+enter the equation disappears and is replaced by the number 6.


I am using LO 4.2.8.2 under Kubuntu 14.04 LTS
Lupp confirmed on 5.0.0.5 and 3.6.5.2 on Windows 8
Comment 1 Jean-Baptiste Faure 2015-09-06 17:27:05 UTC
CSV format is "Comma Separated Value", it is designed to contain values not a to contain formula. Why you do not use a .ods file if you need spreadsheet functionality?
https://en.wikipedia.org/wiki/Comma-separated_values
https://tools.ietf.org/html/rfc4180
Comment 2 rstill74 2015-09-06 18:39:04 UTC
(In reply to Jean-Baptiste Faure from comment #1)
> CSV format is "Comma Separated Value", it is designed to contain values not
> a to contain formula. Why you do not use a .ods file if you need spreadsheet
> functionality?
> https://en.wikipedia.org/wiki/Comma-separated_values
> https://tools.ietf.org/html/rfc4180



I fail to see the relevancy of this question in relation to the bug report. However I am generating the .csv file from another program, and it is much easier to generate a .csv than a .ods. Also, LO will import "regular" (i.e., not array) formulas properly, so somebody much higher on the food chain than me, at least at one point, thought this was desirable.
Comment 3 Wolfgang Jäger 2015-09-06 21:01:34 UTC
LibreOffice might be specified not to recognise any formulas imported from a text file as unformatteed text or opening of a csv. 

But (Check again, please, Jean-Batiste):

{=MATCH(1;ISERROR(A3:A8);0)} as given in the report here is handled inconsistently whether pasted special as unformatted text with Ctrl+Shift+V  copied from a text file or directly entered from the keyboard or contained in a csv file that was opened with Calc. 
It is treated as a text with 28 characters in its cell.
It is edited as a formula of 26 characters without the curly brackets if edit mode is entered, and this in the formula bar and in the cell as well. The range contained also is highlighted then by a border as if a formula is edited. 
Leaving edit mode, however will not make it a working formula but simply restore the curly brackets.

Please note again: The ordinary formulas imported enclosed in "text delimiters" from csv are recognised as formulas and evaluated as such from the beginning! They are not treated as text!

This is inconsistent!

I would suggest to change the subject of this bug into "Inconsistent treatment of array formulas if imported, inserted or entered as text using the curly brackets."

Fixing the issue might, however, require to accept a pair of curly brackets around a formula as an alternative to the special key-grip Ctrl+Shift+Enter, and at the same time to not allow texts matching the pattern {=SomeThing}. This in the line with other strings starting with = or, alas, with - or + in specific cases.
Comment 4 rstill74 2015-09-06 22:45:27 UTC
title changed as suggested
Comment 5 rstill74 2015-09-06 23:34:29 UTC
to Jean-Baptiste Faure:
I wanted to apologize if my response to your message came across as offensive. It was not intended that way. It was merely surprise. 
I admit that I am forcing the venerable .csv format to do things it wasn't really meant to do, but it seems to me that many other parts of LibreOffice and it's documentation implicitly acknowledge that it's not that rare.
Comment 6 m_a_riosv 2016-03-20 22:58:28 UTC
Created attachment 123749 [details]
Sample CSV with SUMPRODUCT() instead brackets.

I think not always but in many situations you can involve the formula with the SUMPRODCUT() function, it is an array function so you don't need the brackets.

And open the csv with it works fine for me.
Comment 7 Buovjaga 2016-03-25 15:58:22 UTC
rstill: regarding comment 6: I am setting to NEEDINFO.
Change back to UNCONFIRMED, if you are not happy with the solution. Change to RESOLVED WORKSFORME, if you are happy.
Comment 8 Xisco Faulí 2016-10-10 11:24:02 UTC Comment hidden (obsolete)
Comment 9 Wolfgang Jäger 2016-10-10 13:27:18 UTC
Created attachment 127920 [details]
The archive mentioned in my Comment#10; Demonstration of the claims
Comment 10 Wolfgang Jäger 2016-10-10 13:29:05 UTC
(In reply to Xisco Faulí from comment #8)
> Dear Bug Submitter,
> 
> This bug has been in NEEDINFO status with no change for at least
> 6 months. ...

I am not the original reporter here. Nonetheless I think I understood the problem and can confirm it. 

A new description might get wordy and not much more clear than it was already tried. Thus I made a demo consisting of 4 files (of which only 3 are relavant.

One is an simple ods containing ordinary formulae and an array formula as well. It was saved while the option 'Display' > 'Formulae' was switched on. 

From this comes the second file to whitch the relevant sheet of the first one was written using 'Save As...'. 

Now a new (untitled) ods document was created and the mentioned csv was used to insert a sheet there. Later it was save to "bug_tdf93973InconsistencyConfirm_1ReloadedFromCSV.ods"

The mentioned files are packed into the attached zip archive. 
Start opening the last mentioned one and read the few lines of text there. You may open the other files then as needed.
Comment 11 Buovjaga 2016-10-10 13:36:46 UTC
Thanks, Wolfgang. Let's set to NEW.
Comment 12 QA Administrators 2017-10-23 14:04:04 UTC Comment hidden (obsolete)
Comment 13 Wolfgang Jäger 2017-10-23 17:05:04 UTC
The link to late en.libreofficeforum . org in the original post is broken due to the shutdown of that forum (sigh). 

There is a (not searcheble) archive where you still find the thread under discussion: http://www.imaccanici.org/en.libreofficeforum.org/node/11459
Comment 14 Wolfgang Jäger 2017-10-23 17:39:42 UTC
Tested again with V5.4.2. on Win 10:

Behaviour still as described in the original report. 

Emphasizing the inconsistencies: 

-1a- Non-array formulas are recognized as formulas on import. 
-1b- Array formulas are not. They are dysfunctional and shown as texts.
-1c- 'Numbers' format of the respective cells remains 'General'.

-2a- Going edit mode (F2, not the wizard) the mode is "formula-editing": Emphasizing references, no curly brackets.
-2b- Escaping the edit: Formula is text again - with curley brackets. Still 'General' numbers format.
-2c- The wizard doesn't regognize a formula at all.
Comment 15 QA Administrators 2018-10-24 02:56:22 UTC Comment hidden (obsolete)
Comment 16 Wolfgang Jäger 2018-10-24 10:19:01 UTC
Tested again with V6.1.3.1RC. 

Behaviour unchanged. (Please also read the final paragraph thoroughly.)

I already included a suggestion with my demonstrations to solve the issue by creating an alternative way to enter a formula for array-evaluation. See file bug_tdf93973InconsistencyConfirm_1ReloadedFromCSV.ods contained in the .zip attached to Comment #10. 

This second way was to simply enclose the formula in curly brackets as it is displayed anyway after being recognised. 

Concerning the present case of importing formulae from a csv this might be accomplished by finding the output range for the top-left occurrence of the formula with a query for the range of its adjacent repetitions. 

I'm inerested in your comments on the question if filing that suggestion as a feature request (enhancement "bug") might be the better way to get the old issue resolved.
Comment 17 QA Administrators 2019-10-25 02:40:44 UTC Comment hidden (obsolete)
Comment 18 Wolfgang Jäger 2019-10-25 19:40:13 UTC
Tested with V 6.3.3.1rc
Behavioiur unchanged.
Comment 19 QA Administrators 2019-10-26 02:10:14 UTC Comment hidden (obsolete)
Comment 20 Wolfgang Jäger 2019-10-26 09:30:17 UTC
Created attachment 155322 [details]
Example with directly entered text looking like array formula

I don't know if the original reporter (rstill74) continues to observe this bug, but:

I tested with V 6.3.3.1rc and the described behaviour was unchanged. 

Hoping to get things even more clear I attach a very simple example .ods made with the mentioned version where the text contents looking like a array formulae were directly entered using the keyboard. The effects are the same as with content read from a csv file.
Comment 21 QA Administrators 2021-10-26 04:44:11 UTC Comment hidden (obsolete)
Comment 22 Eike Rathke 2023-08-27 22:14:30 UTC
Array formulas can't be created by text import that way. Period. Not a bug. Won't fix.