Openrefine: Add new Column Operation "Pad Column to length"

Created on 29 Jan 2018  路  8Comments  路  Source: OpenRefine/OpenRefine

From @ettorerizza
"A padding function is definitely needed in the menu. Meanwhile, the fact that Open Refine does not show consecutive spaces does not help to solve the current problem."

From @thadguidry
Perhaps there is a need to have a simple column operation for this also , besides some new GREL value.format() syntax or a toString(" ") format override ?
"Pad column to length..." where the dialog has 2 arguments, the column length, and an input box to type in the character to pad with (users could type a whitespace, zero, whatever).
hmm....and suffix or prefix or both padding checkbox options.

enhancement Medium

Most helpful comment

Since most data cleaning softwares have a function for padding, it must be a common need. @magdmartin gives a workaround in GREL, but it's quite difficult to remember.

All 8 comments

It looks like this could be done by adding the appropriate GREL function.

About displaying consecutive spaces, I also think this is an issue but I am not sure how to go around it. Replace all spaces by non-breaking spaces when displaying a cell? That will break word-wrap (and we are distorting the content).

@wetneb #1286 is the issue discussing the HOW-TO proposal for the display of Unprintable Characters, which could tie into @ettorerizza need. Formatting or changing the display of data so you can understand or work with it better, while keeping the raw data in the backend storage. A toggle mode is best for this, like other data tools do. Regardless, I would say its not "distorting" that we are after here, but the opposite by giving hints, highlighting, applying certain formats, etc. (with colors other than black and white, which sucks sometimes) to make visualization easier. And yeah, that work will be cumbersome for sure, but worth it. (BTW, Where's our UI Gods when we need them !?!? lolol)

Since most data cleaning softwares have a function for padding, it must be a common need. @magdmartin gives a workaround in GREL, but it's quite difficult to remember.

See #1354 for the display of consecutive spaces (separate to the display of non-printing characters). I think it is just an easy css fix tbh but I need to try it and test

1497 implemented the display of consecutive spaces

Thinking that the padding could be done by adding 'lpad' and 'rpad' functions to GREL, following similar rules to

@ostephens Ah yeah, this issue was because I normally just need RPAD, but sure, why not both ! And the terms lpad() and rpad() are nice and GREL like already :) short and sweet.

Just noted that org.apache.commons.lang3.StringUtils (which we already use) has leftpad and rightpad functions which we can probably use to create GREL lpad() and rpad() functions

Was this page helpful?
0 / 5 - 0 ratings