It's a bit of a PITA to open a delimited text file with Calc, as the "Text" filter always loads the document in Writer, and the "Text CSV" filter only lists *.csv files. The filter should be called something more appropriate like "Delimited Text", and include *.txt as well as *.csv files (and perhaps more).
(In reply to Mike Ruskai from comment #0) > It's a bit of a PITA to open a delimited text file with Calc, as the "Text" > filter always loads the document in Writer That is not true. If the file is opened from an existing Calc window, it will be opened in Calc too. > and the "Text CSV" filter only > lists *.csv files. That is because this filter is import/export, and 'csv' is the extension for export. I don't know if there can be more than one. This filter uses 'Text' type, which is also used by Writer. So the detection code contains a few simple heuristics that try to guess if the file should be opened in Writer or Calc. I think a possible course of action is to define a separate type for it, say 'Delimited Text'. Possible workarounds: rename the file before opening it; open the file from an existing Calc window.
What is needed here: Create a new filter type delimited_Text as a copy of filter/source/config/fragments/types/generic_Text.xcu . Change filter/source/config/fragments/filters/Text___txt___csv__StarCalc_.xcu to use it. Modify PlainTextFilterDetect::detect in filter/source/textfilterdetect/filterdetect.cxx to handle delimited_Text in addition to generic_Text and to always set CALC_TEXT_FILTER in that case. Check that various use cases work as expected: e.g., open a .txt/.csv file from an existing Calc/Writer window with specifying a type, then without it, then directly from the Start Center, etc.
(In reply to David Tardon from comment #1) > (In reply to Mike Ruskai from comment #0) > > It's a bit of a PITA to open a delimited text file with Calc, as the "Text" > > filter always loads the document in Writer > > That is not true. If the file is opened from an existing Calc window, it > will be opened in Calc too. I take it you're aware by now that this claim is not true. Opening a delimited text file from Calc using the "Text" filter sends the file to Writer. > > and the "Text CSV" filter only > > lists *.csv files. > > That is because this filter is import/export, and 'csv' is the extension for > export. I don't know if there can be more than one. Normal UI design uses a filter with all eligible extensions for opening a file, with a specific extension for saving a file. The latter can either be through separate filters, or a filter with multiple extensions selected via a dropdown on the file dialog. > This filter uses 'Text' type, which is also used by Writer. So the detection > code contains a few simple heuristics that try to guess if the file should > be opened in Writer or Calc. I think a possible course of action is to > define a separate type for it, say 'Delimited Text'. Such a separate filter is what I think makes the most sense. It's really what "Text CSV" already is, save without the file extension limitation. That filter is currently the only way to save a delimited text file of any kind.
I'm the original author of the part of the detection code that handles generic text file type. We need to be careful not to confuse format "types" and "filters". A type only refers to a format type such as HTML, plain text etc, and is not tied to a specific application such as Writer or Calc. A filter OTOH is tied to a single application. We have one plain text filter for Writer and one plain text filter for Calc. The one for Writer treats all plain text files equally whereas the one for Calc treats all plain text files equally as CSV, regardless of extension. OTOH, we only have one generic text type that's application agnostic. During detection phase, when a plain text "type" is detected, it does its best to tie that to a specific filter which in turn determines which application the file will be opened. Part of the confusion comes from the fact that we do list all available "filters" as file "types" in the UI, which IMO is not correct. As such, if you specify in the UI the "Text" type which really is a text filter for Writer, the file will be opened in Writer even if you do this from Calc window before what that "Text type" represents is the plain text "filter" for Writer. Perhaps the right solution would be to change the UI label from "file types" to "file filters"? Either way, we do need to make the correct distinction between file types and file filters and do understand the differences between the two before trying to come up with what would be the right solution for this. Just my 2 cents.
And I swear this UI label used to be "file filters" not "file types".... though my memory is a bit hazy.
Do not trust your memory, trust the version control system :-)
(In reply to jan iversen from comment #6) > Do not trust your memory, trust the version control system :-) Absolutely right. Would you mind looking into that? :-) I might do it later when I find time but I'm a bit short on time at the moment.
JanI is default CC for Easy Hacks (Add Jan; remove LibreOffice Dev List from CC) [NinjaEdit]
One problem here is that when I enter file mask into filename field, I expect selected import filter to remain the same, but file list should now follow selected file mask. (E.g., if import filter selected is CSV, it shows only CSV files - OK; now I enter *.txt into filename and press Enter - and I want to see list of TXTs, but the import filter should stay CSV). What actually happens is that import filter changes to Text files (txt). So the only way to actually open the csv-in-txt is to type the file name by hand (or select it while TXT filter is active, so that it's in filename, and then change filter). The above is on Windows.
A polite ping, still working on this bug
Yes i'm still working on the issue. Haven't that much time for 4 months (Birth of my daughter :))
A polite ping, still working on this bug?
This should not only include .csv and .txt! There can be an infinite number of file extensions with csv or tsv data. To name a few that I have worked with myself: *.tsv, *.log, *.cal, *.lmp, *.sts, *.ies. Some just happen to have data with a delimiter, others are designed but specific for a certain industry (e.g. ies are goniometric radiant flux measurements in csv format)
Dear tvallois, This bug has been in ASSIGNED status for more than 3 months without any activity. Resetting it to NEW. Please assigned it back to yourself if you're still working on this.
Using version 7.1.1.2, there is a "Text documents" filter that seems to open the import dialog in Calc for .txt documents. Also, other file formats can be filtered in the file name field (e.g. *.tsv) using the "All files" filter and still open with the import dialog in Calc. Maybe just the default behavior for the "Text" filter should be changed to match the "Text documents" filter? One thing I noticed is that filter is ignored if the file to be opened is already open -- not sure if this is expected.
(In reply to Matt K from comment #36) There are several possible approaches here. And the most user-friendly one seems to be to simply /add/ *.* (see comment 18) or some specific extensions (txt in comment 0; tsv in your comment 36) to the text filter extension list, so that the dialogs show all files. Another one (see comment 9) would require users to know that they may enter new mask - not a common knowledge. The one from comment 2 IMO would be a bit of overkill...
(In reply to Mike Kaganski from comment #37) > (In reply to Matt K from comment #36) > > There are several possible approaches here. And the most user-friendly one > seems to be to simply /add/ *.* (see comment 18) or some specific extensions > (txt in comment 0; tsv in your comment 36) to the text filter extension > list, so that the dialogs show all files. Another one (see comment 9) would > require users to know that they may enter new mask - not a common knowledge. > The one from comment 2 IMO would be a bit of overkill... Do you mean add *.* to every text filter list (there are many, such as "Text documents" and "Text (StarWriter/Web)")? Doing that, I think the issues raised in comment 3 would still exist; should we also address those issues?: (1.) opening a file in Calc with the "Text (*.txt)" filter sending the file to Writer (2.) Allowing the user to save a delimited text file with any extension rather than just .csv.