intellij-csv-validator icon indicating copy to clipboard operation
intellij-csv-validator copied to clipboard

Why was column alignment removed?

Open JAK0723 opened this issue 2 years ago • 8 comments
trafficstars

The main features that I use from this plugin are the rainbow colouring and the column alignment on formatting. Without the column alignment in version 3.0.1, this plugin is much less useful for me.

I've downgraded the plugin to 2.21.0 to regain column alignment. Hopefully it will remain compatible with future versions of JetBrains IDEs.

JAK0723 avatar Nov 21 '22 07:11 JAK0723

I agree 100%. Those features, column coloring, and "Tabularize/table" formatting were the primary reasons I used the plugin. I have also taken the same action, and I also wonder how well that will work going forward. I am really sad that the feature was not made configurable, rather than removed. Of course, there is more detail that I haven't been able to gather, but I hope the behavior can be reinstated, or somehow added to another plugin.

violanotes avatar Dec 21 '22 04:12 violanotes

Thanks for all the feedback! Its great to hear that this feature was used, as it was actually the main reason for me to start this plugin.

However, this was some years ago with version 1 not having a table editor. In version 2 a table editor was introduced, but the implementation and data handling was very disconnected to the underlying document. For example, one cell change would rewrite the whole content, comments couldn't be edited, and it was extremely slow.

So I decided to rework it completely to make it really usable, also for large amount of data. One way to achieve this is to operate on the parsed data directly, not using an own data structure. Another important piece was to improve the parsing in the first place to consider whitespaces part of the value, instead of having a special treatment for them.

This brings me to the actual reason why I decided to drop the Tabularize feature: It uses whitespace for formatting, but technically they are part of the value.

When using the table editor on top of tabularized data, you get values containing whitespaces, like val1 or col2.

When thinking about it, I ended up with the following scenario:

  1. Lets trim the value for the table editor! But this would actually alter the value, and how could someone add whitespace to the beginning or end if it is intended?
  2. Put double quotes around fields that start or end with a whitespace, e.g. "val1 " if the whitespaces are intentional. Then the tabularization could be done outside the quotes:
"col1"    ,col2
"value 11",value 22
"val1    ","    val2"

But this doesn't look clean and useful anymore, it negates the purpose of tabularization. Furthermore, how to distinct intentional and formatting whitespaces in the first place (e.g. opening an existing file)? And then the user needs to take extra care for the quoting in general.

  1. Adding additional settings and parameters to define the wanted behavior. I would consider this a mitigation, not a solution. And it's maintenance hell.

I was striving to simplify the editing of CSV with the new version, therefore I removed all the buttons in the table editor and invested quite some time in proper keyboard shortcuts. For me, the table editor is now the right way to view and edit CSV files. The tabularize functionality was an initial way to work around the missing table view.

Said all this, I am not opposed of having this feature in general if I notice a great demand for it. But it needs to contribute to a coherent and understandable CSV editing experience supporting the text as well as the table editor.

Suggestions/discussions welcome!

SeeSharpSoft avatar Dec 21 '22 13:12 SeeSharpSoft

I suppose that's understandable considering that you decided to go all-in on the table-editor.

Is it possible that a fork or alternate version or an entirely new plugin can be made that only has the column colouring and the tabularize formatting? That way people who want to use the table-editor can use the main version, while people that prefer editing plain CSVs can use the alternate version.

The reason why I suggest creating an alternate version instead of just downgrading to 2.21.0 is that the alternate version could be maintained. It's possible that an update to JetBrains IDEs could break the functionality of 2.21.0, while an alternate version could be updated to remain compatible with new JetBrains IDEs updates. I doubt that any new features would be added to the alternate version, just fixes.

JAK0723 avatar Dec 21 '22 13:12 JAK0723

I'm stunned this feature was removed. I use it at work to store excel-style data as TSV, but also editable as a text file outside of IntelliJ!. It took me a while, searching the settings pages, to find out it was removed. That's what I get for not reading the release notes. I tried the new table editor but immediately hit a roadblock there. I can't insert and paste (a) line(s). It pastes the entire clipboard into the first cell. I have many other qualms with this table editor, including ahem performance. Back to version 2.

An option for a consistent implementation is this: When all strings are quoted, there's no problem with spaces outside of the quotes. When reading (or saving) a CSV/TSV/PSV file that has unquoted strings with trailing spaces, you could ask the user what to do. Store the choice in the project's csv-editor.xml.

MarkJeronimus avatar Jan 13 '23 11:01 MarkJeronimus

It seems this was a more popular feature than expected, is there a way to have it be a 'user_selectable' function with its caveats and disclosures of possible issues?

I'm still using it more and more but this is a great plugin for PyCharm thank you!

datatalking avatar Feb 03 '23 17:02 datatalking

This feature is also the primary reason I used this plugin, there is not a conforming usage of the plugin on my team so some users will manually add whitespace to align the columns and other used the plugin to auto format for them.

Perhaps to support wider use cases, the formatting can be configurable, whether the user wants to exclude white space formatting inside double quoted values, or include them

Huynhs avatar Aug 16 '23 14:08 Huynhs

As my Java probably isn't up to par to solve this, can anyone look into the codebase to find places we can start looking to give us a place to start?

If this was written in Python, Rust, R or SQL I could dig into the code, but this is still a useful feature so I'll try to support where I can.

datatalking avatar Aug 25 '23 19:08 datatalking

Soon we are going to be stuck with an old IntelliJ

com.intellij.diagnostic.PluginException: ActionUpdateThread.OLD_EDT is deprecated and going to be removed soon. 'net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeEscapeCharacterActionGroup' must override getActionUpdateThread() and chose EDT or BGT. See ActionUpdateThread javadoc. [Plugin: net.seesharpsoft.intellij.plugins.csv]

Is there already some progress in reintroducing column alignment?

MarkJeronimus avatar Jul 11 '24 07:07 MarkJeronimus