How to concatenate strings with padding in sqlite

The || operator is “concatenate” – it joins together the two strings of its operands. From http://www.sqlite.org/lang_expr.html For padding, the seemingly-cheater way I’ve used is to start with your target string, say ‘0000’, concatenate ‘0000423’, then substr(result, -4, 4) for ‘0423’. Update: Looks like there is no native implementation of “lpad” or “rpad” in SQLite, … Read more

How to remove leading and trailing zeros in a string? Python

What about a basic your_string.strip(“0”) to remove both trailing and leading zeros ? If you’re only interested in removing trailing zeros, use .rstrip instead (and .lstrip for only the leading ones). More info in the doc. You could use some list comprehension to get the sequences you want like so: trailing_removed = [s.rstrip(“0”) for s … Read more

tech