I have some fields that are really long, but I just want to see the beginning of them. Is there a way to truncate a field to only the first X characters?
Insert the TRUNC formula. In the first cell of the column, you want to populate with the truncated number, type an "=" sign to indicate you're using a formula. Then type TRUNC. Use an open parenthesis to add the operators of the formula. The first number you enter is the number you want to truncate.
What is the Truncate Command in SQL? We use the Truncate command to delete the data stored in the table. The working of truncate command is similar to the working of Delete command without a where clause.
The formula is "=DIRECTION(Cell Name, Number of characters to display)" without the quotation marks. For example: =LEFT(A3, 6) displays the first six characters in cell A3. If the text in A3 says "Cats are better", the truncated text will read "Cats a" in your selected cell.
If you mean by trimming long strings, sure. Figure out which strings to trim then trim them.
e.g., trimming a string to the first 10 characters
$ echo '"12345678901234567890"' | jq '.[0:10]'
Read, take the first 0-10 characters of the string.
If you want to recursively trim all strings:
.. |= (if type == "string" then .[0:2] else . end)
For example, if the input is:
{"a": "aaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"b": "bbbbbbbbbbbbbbbbbbbbbbbbbb",
"c": ["ddddddddddddddd"]
}
the output (compacted) would be:
{"a":"aa","b":"bb","c":["dd"]}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With