|
Is there a way to have rails print out a number with commas in it?
For example, if I have a number 54 .34, I can run <%= number.function %>, which would print out "54,000,000.34"
thanks!
Started by Jess on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
For example:
<%= ....
Number_with_delimiter(98765432.98, :delimiter => ",", :separator => ".") # => 98,765,432.98
You want the number_with_delimiter method .
The method you are looking for is number_with_delimiter.
Yes, use the NumberHelper.
|
|
I need a regex that converts commas to spaces. I know this is super simple, but i do not know regex. thanks.
tag1, tag2, tag3, tag4,tag5 tag6
to
tag1 tag2 tag3 tag4 tag5 tag6
thanks
Started by laxj11 on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Tag6');
If some of your tags without commas between them have more than one space, you could use.
|
|
How can I parse a float scanned from a sheet as text, containing commas?
txt = "1,903.44" value = float(txt) # This fails due to ',' in string
UPDATE: Sorry I wasn't clear. I'm using jython 2.5, which doesn't have the locale module.
Started by gregturn on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
You could strip the commas:
txt = txt.replace(',', '') value.
Use locale.atof() after locale.setlocale(locale.LC_ALL, '').
Work but it does the trick if you know that commas are your separators.
|
Ask your Facebook Friends
|
I have a mathparser that can do functions like "IntPow(3,2)". If a user pastes "1,000,000" and then adds a plus symbol, making the full equation "1,000,000+IntPow(3,2)" the parser fails because it does not work with numbers that contain commas.
I need...
Started by John Rennemeyer on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
If you read a comma, delete it if the counter is 0, otherwise....
If you read a ')', decrement that counter.
If you read a '(', increment a counter.
The easiest.
But what if a user pastes:
1,000+IntPow(3,000,2,000)
Now the 3,000 is between comma's.
|
|
I have a large csv file with a mix of character and numeric columns. Some of the numerical values are expressed as strings with commas. e.g., "1,513" instead of 1513. What is the simplest way to read the data into R?
I can use read.csv(...,colClasses=...
Started by Rob Hyndman on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Then remove only those the commas.
, 1,234,567, rrr"
Can use readLines on a textConnection.
|
|
The data I need to parse looks like:
[fild1, filed2, .... filedn] , [filed1, filed2, .... filedn]
I call it a special form of CSV data because there are two kinds of comma:
those commas outside the [] pair are served as the separator between different...
Started by Haiyuan Zhang on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
How about: my @parts = split(/\]/, $data); , and then you can iterate over @parts , remove the heading [ and split once more by ","
You can also make the initial split like so: my @parts = split(/\] , /, $data); and that will save you some more cleanup... .
|
|
I have this string:
1001,"Fitzsimmons, Des Marteau, Beale and Nunn",109,"George","COD","Standard",,109,8/14/1998 8:50:02
What regular expression would I use to replace the commas in the "Fitzsimmons, Des Marteau, Beale and Nunn" with a pipe | so it is...
Started by Brandon on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
I believe this is going to be....
There is a good (free) java library for parsing CSV files called opencsv .
While it would be possible to do with regular expressions, it would be much clearer to first split the line into fields, then do the replacement .
|
|
I need to convert a string like this:
tag, tag2, longer tag, tag3
to:
tag, tag2, longer-tag, tag3
To make this short, I need to replace spaces not preceded by commas with hyphens, and I need to do this in Javascript .
Started by kari.patila on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
I've now updated my/g, function($0, $1){ return $1 ? $0 : '-'; });
([^,] ) - first character is not comma, the second.
Remember the syntax
[^,] = Not a comma
Edit Sorry, didn't notice the replace before.
|
|
I have a classic ASP page that submits back to itself. Strangely, the values being returned from the selects have commas being added to the ends of them. Has anyone run into anything like this before? Any troubleshooting steps or tools recommended?
I'...
Started by Kat on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Your values are concatenated together with commas, like if the data is actually being posted with the commas or if it's happening after ASP gets its awful paws form values with the same name are....
Sounds like you have duplicate form fields.
|
|
Hi,
I want to remove all unnecessary commas from the start/end of the string.
eg; "google, yahoo,, ," should be like "google, yahoo".
and if possible ",google,, , yahoo,, ," to "google,yahoo".
I tried, the below code, but seems to be not working,
trimCommas...
Started by Mithun on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
This handles the edge implemented....
Need to do is replace all groups of "space and comma" with a single comma and then remove commas and commas with a single comma, provided there's at least one comma in there.
|