mechatroner / vscode_rainbow_csv

🌈Rainbow CSV - VS Code extension: Highlight CSV and TSV files in different rainbow colors to make them more readable
MIT License
426 stars 51 forks source link

Option to align numbers #106

Closed 7keo closed 2 years ago

7keo commented 2 years ago

Issue:

Currently numbers align like this:

(Default: Align numbers to the left)

7
14
1.05
103
52.1

Desired:


Thank you.

PS: This extension is great!

mechatroner commented 2 years ago

Cool, thanks, this is very interesting! Would never think about this myself, but it seems to be a pretty standard way to align numbers: https://ux.stackexchange.com/questions/13795/is-there-a-standard-to-left-justify-text-and-right-justify-numeric-values I will plan to add this feature, maybe this should even be the default behavior, IDK. The aligning algorithm makes 2 passes anyway - the first pass to determine max string width, and the second pass to align. So during the first pass, we can check if the current column is an integer or float which should be pretty straightforward with a simple regex.

mechatroner commented 2 years ago

There will be a ton of corner cases though: aligning percent values, scientific notation, columns with NaNs, etc. But probably even the most basic algorithm will cover the majority of cases.

mechatroner commented 2 years ago

I just published version 2.3.0 which does numeric alignment by default. The following corner cases are handled: