Hi currently i have code which convert a number into two decimal places in Thymleaf.
<h6 class = "font-weight-bold"
th:text="${#numbers.formatDecimal((purchase.itemPrice * purchase.count),1,2,'POINT')}">
I want to make this number also comma separated.How can i do that?
Related
I have a column which contains comma seperated numbers
A1: 004,005,0005,00005
I want to split and more stuff with this. When I split I end up with the following. Losing the zeros because excel parses them as text
=split(A1, "," )
4 | 5 | 5 | 5
instead of
004 | 005 | 0005 | 00005
The number of zeros is important. I will pass on the result to get a vertical list
=unique(transpose(arrayformula(trim(split(join(",",!A1:A),",")))))
Adding a single quote before a number will keep the format as is, thus, keeping the leading and trailing zeroes. Please see formula below:
=SPLIT(SUBSTITUTE(","&A1,",","#'"),"#")
Try this:
=ArrayFormula(REGEXREPLACE(SPLIT(REGEXREPLACE(A1,"(\d+)","~$1"),","),"~",""))
What this formula does is first replace every group of numbers with a tilde (~) and that same group of numbers. When SPLIT then acts on this new configuration, splitting at the commas, every group of numbers has the tilde in front of it and so retains all digits (because it is seen as a string and not a number). Finally, the outer REGEXREPLACE just gets rid of the tildes.
With just a single value in A1 you can use a little trick I described over at "Web-Applications" in this cross-website post:
=SPLIT(SUBSTITUTE("'"&A1,"#","#'"),"#")
The single quote will force GS to format the returned elements as being text. We can use this principle inside an arrayformula if you have to concatenate multiple strings. You don't need ARRAYFORMULA() per se, but instead of JOIN() you'd need TEXTJOIN() to use the 2nd parameter and exclude empty cells from being joined.
Formula in B1:
=UNIQUE(TRANSPOSE(SPLIT(SUBSTITUTE("'"&TEXTJOIN(",",TRUE,A1:A),",","#'"),"#")))
I am using the following formula to extract the substring venue01 from column C, the problem is that when value string in column C is shorter it only extracts the value 1 I need it to extract anything straight after the - (dash) no matter the length of the value text in column c
={"VenueID";ARRAYFORMULA(IF(ISBLANK(A2:A),"",RIGHT(C2:C,SEARCH("-",C2:C)-21)))}
There is a much simpler solution using regular expressions.
=REGEXEXTRACT(A1,".*-(.*)")
In case you are no familiar with Regular Expressions what this means is, get me every string of characters ((.*)) after a dash (-).
Example
Reference
REGEXTRACT
Test regular expressions
Cheat sheet for regular expressions
To answer bomberjackets question in the comment of Raserhin:
To select the part of the string before the "-"
=REGEXEXTRACT(A1,"(.*)-.*")
EXAMPLE
example of code
Adding to your original formula. I think if you'd use RIGHT and inside it reverse the order of the string with ARRAY then that may work.
=Right(A1,FIND("-",JOIN("",ARRAYFORMULA(MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1))))-1)
It takes string from the right side up to X number of characters.
Number of character is fetched from reversing the text, then finding
the dash "-".
It adds one more +1 of the text as it will take out so it accounts
for the dash itself, if no +1 is added, it will show the dash on
the extracted string.
The REGEX on the other answer works great too, however, you can control a number of character to over or under trim. E.g. if there is a space after the dash and you would like to always account for one more char.
I have tried to use extended function to separate these values but the problem is that I am able to separate only one value.
https://isu.ifmo.ru/docs/XMLP/help/en_US/htmfiles/B25951_01/T421739T421827.htm
You will have to use some text processing functions on each of the parameter. Say, if $name is the parameter which contains the comma separated data, then
<?xdofx:Instr($name,',',1)?> will give you the position of the comma in the text.
Then <?xdofx:substr($name,1, Instr($name,',',1)-1)?> will return the text before the comma.
And. <?xdofx:substr($name,Instr($name,',',1)+1, length($name))?> will return the text after the comma
first,last
6
first
last
I have inserted the comma separated values into mnesia table column as {"11,1,15"}
After retrieving from table Now i need to extract these comma separated values. while extracting these 11,1,15 as separate values, I am getting problem, because it returning value in below format.
49 | 1,1,12.
But here i need them separately as integer digits.
Can you point me in correct direction? where I am making mistake?
If you want to convert a string of comma separated integers into a list of integers, this can help:
1> String = "11,1,15".
"11,1,15"
2> [list_to_integer(I) || I <- string:tokens(String,",")].
[11,1,15]
This seems like it should be simple.
I have a CSV file with multiple currency values (so I'd like to avoid writing a bunch of string-manipulation steps if it can be avoided), and I was excited to see that the CSV File Input step has fields like Currency Separator, decimal symbol, grouping symbol (and mine are the default "$", ".", and ",", respectively).
The documentation describes these as for:
Currency Used to interpret numbers like $10,000.00 or E5.000,00
Decimal A decimal point can be a "." (10;000.00) or "," (5.000,00)
Grouping A grouping can be a dot "," (10;000.00) or "." (5.000,00)
(http://wiki.pentaho.com/display/EAI/Text+File+Input)
But as of the current production version (4.4)... these settings do not seem to have an effect.
Has anyone had success with number masks or similar such that a string like "$10,000,238.48" can yield a number that can be pushed into a database? Anything I do is either "Unparsable" in the text input or "truncated field" error at the insert...
When I do a get fields on a text input step with your example number in it, it sets Currency, Decimal, and Group to '$', '.', ',' respectively, and it reads your number just fine. It also sets a Format string of '$#,##0.00;($#,##0.00)', which it seems is the key piece. The text file input step will examine as many rows as you specify from a CSV and guess the formats for each column.
Here is PDI's number formatting table:
Number Formatting Table
If you have different currency formats mixed in the same column, I would use a UDJE step and this answer:
Parsing a Currency string in Java
Or a JavaScript Step and this answer:
Convert Currency string with JavaScript
to strip out all non digit and non decimal point characters, then pass it through a Select Values step. Note, that this will be very tricky if you have mixed decimal separators in the input column.