removing commas
hi there,
i was looking around but haven't found anything that helps me to do this.
i have a long list of number with commas. i would want to sum all these values together, but my zl sum doesn't accept commas. could someone guide me to the objects that i can cut and paste from a text program, into textedit (max obejct) to remove commas and then gives me the output of the sum.
any advice?
best
Maybe like this?
Beware: if the list if really long, you may have to change the maximum list length in the zl objects.
p
I'm at work, so I can't check Patrick's suggestion (he may be saying the same thing), but I've done some things with [atoi] into [zl filter] into [itoa] to remove spaces and other characters from messages. You just need to figure out what a comma is as an integer and then make that the filtered number.
Or use [accum]?
hi!
thanks for the tip and patch. yes i forgot about itoa and atoi. yes accum works as well. thanks for the advice.
have a nice day.
best
d
Hi all, this was a great solution (the patch to load from the clipboard), and in the picture another solution. But how to change a number like this one inside a list or a text?...like <title>Coronavirus Update (Live): 48,090,004 Cases and 1236943 Deadths </title> in <title>Coronavirus Update (Live): 48090004 Cases and 1236943 Deadths </title> ?? (the second number is just a int)

atoi > filter commas out >itoa
Doesn't work, first of all the numbers separated by commas, have to transformed in symbols...it's not so easy.... In the picture: the first case works, the second one not (but this is the standard how this number is written...not a symbol...)

Seems a old problem... https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
You seem to like screenshots :

there are more ways to do this, but I am too lazy to type much into regexp and combine.
Playing lego with max objects makes more fun
Thank you Source Audio... but there are two problems: your patch is fixed (assuming the numbers with a comma are in a fixed position...but it’s not true, also the second number has commas, I’ve removed them for displaying purpose only), second problem is that the first numbers are in reality 48 090 004, and the zeros at the beginning will be removed because they are numbers and not symbols. The ending number should be 480900004 and not 48904! The right way should be first to find the entire number with commas (48,090,004), then transform this number in symbols, then his position, extract it, convert it and replace it as int in the same position. It’s harder like it seems. Your solution can also be obtained in other ways, but the only one solution I can think is to perform a recursive search using a regexp, but the re .+(?i:\\,?).+ is not working, and I’m stuck here.... thanx anyway.
There is no solution to anything in THIS out.
You must set some rules, but then if expected input
does not match - again not working.
You could have stated from the beginning exactly what you want.

Thank you again, but it's still not working because the initial message contain numbers not indented as a symbol! it's like this one; <title>Coronavirus Update (Live): 48,090,004 Cases and 1236943 Deadths </title> and not <title>Coronavirus Update (Live): "48,090,004" Cases and 1236943 Deadths </title>... the first case is too easy to solve....
...see this patch, double clicking (or opening) (on) the [text] object...

Why should one format a number 4809004 as 48,090,004 in first place ?
And why do you store that into text edit which anyway does it's own thing
and want to format a number at output in that way ?
Use my last patch and convert the string before storing it into text edit.

Text edit will store and output what you wanted,
If I understand at all what that at the end is.
you could also remove every 4th symbol from the reversed and atoi´ed data stream, then rebuild the list.
Hi all!
the formatting is not my thing! The message, one of them and they can have hundred of numbers and lines, comes from a [jit.uldl] obj from a web page to a [jit.textfile] obj, I can't format the numbers, they are inside the message! And I put the string in a text obj so you can see the original formatting, the message obj don't do it in the same way,
very first solution from source audio had it all already i think:
"atoi > filter commas out >itoa"
this works with arbitrary input. as long as the numbers are always divided from the rest using spaces, you can now do [route int] and only the numbers will be left.
Perhaps I've misunderstood the requirement here, but it seems it's elegantly solved with a RegEx;
Thank you Nick, thanx for your time!!!
Sorry, the regexp is working well, but the main problem is still there. See this patch, (the text obj is there to see how exactly the message is received):

I played around with the text object for a bit, and yeah, it seems to treat the lines of the file as messages (as opposed to symbols), and not really any way around that (with that object) - at least, I can't find a way.
However, if you use the js object (and in that the JavaScript File object), you can quite easily read the file and return them as symbols (as if the whole line was in quotes).