Hi, what is the better way to replace the , (comma) with a space char? Example:STRING=dir1,dir2,dir3 toSTRING=dir1 dir2 dir3 And.. how to find if in the string there is a comma?
Thanks :) (6 Replies)
Hi,
I am trying to truncate word after comma in a file ONLY if there are already 2 words BEFORE comma. If there is one word or 3 or more words BEFORE comma, then I have to leave the data AS IS. See below for example.
Input File :
John Smith, Manager
Smith, John Frank
J F K... (2 Replies)
Hi,
The input file structure is given below: The Col1 and Col2 will be there always. But from Col3 there can be more columns.
And Col3 will be always Col4 and Col5 will always be with Col6. I need to replace the | with comma. There are scnearios where there
wont be no data.Below, the row 2... (6 Replies)
Hello everyone,
I want to replace all "," (commas) with a blank space
My command thus far is:
cat test.text | sed -e s/\`//g | awk '{print$1" "$2" "$3}'
I'm sure you guys know this, but the SED command that I am using is to get rid of the "`" (tics).
which gives me:
name ... (5 Replies)
Hi
Can any one pls tell me how to grep this line
POPULATION,69691,20120509
I want the number 69691 from the above line.
How to grep from the first comma till the next comma.
Thank You.:confused: (8 Replies)
Hello there,
I have a comma separated csv , and all the text field is wrapped by double quote. Issue is some text field contain comma as well inside double quote. so it is difficult to process.
Input in the csv file is ,
1,234,"abc,12,gh","GH234TY",34
I need output like below,... (8 Replies)
I'm using sh on hp-ux. I've got a file that looks like this.
-5.65 175
-16.17 160
-13.57 270
-51.72 260
-8.30 360
-42.71 460
-.38 375
-.20 375
-4.15 170
-21.53 560
-18.84 360
I'd like to replace all the whitespace between the columns with one comma. I can't... (4 Replies)
I have a comma delimited file of major codes and descriptions. I want to replace all occurrences of spaces with underscores up to the first comma (only in the first field), but not replace spaces following the comma. For instance I have the following snippet of the file:
EK ED,Elementary and... (7 Replies)
Hi Experts,
Please support
I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6.
... (3 Replies)
Discussion started by: as7951
3 Replies
LEARN ABOUT PHP
number_format
NUMBER_FORMAT(3) 1 NUMBER_FORMAT(3)number_format - Format a number with grouped thousandsSYNOPSIS
string number_format (float $number, [int $decimals])
DESCRIPTION
string number_format (float $number, int $decimals, string $dec_point = ".", string $thousands_sep = ",")
This function accepts either one, two, or four parameters (not three):
If only one parameter is given, $number will be formatted without decimals, but with a comma (",") between every group of thousands.
If two parameters are given, $number will be formatted with $decimals decimals with a dot (".") in front, and a comma (",") between every
group of thousands.
If all four parameters are given, $number will be formatted with $decimals decimals, $dec_point instead of a dot (".") before the decimals
and $thousands_sep instead of a comma (",") between every group of thousands.
PARAMETERS
o $number
- The number being formatted.
o $decimals
- Sets the number of decimal points.
o $dec_point
- Sets the separator for the decimal point.
o $thousands_sep
- Sets the thousands separator.
RETURN VALUES
A formatted version of $number.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.4.0 | |
| | |
| | This function now supports multiple bytes in |
| | $dec_point and $thousands_sep. Only the first |
| | byte of each separator was used in older ver- |
| | sions. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
number_format(3) Example
For instance, French notation usually use two decimals, comma (',') as decimal separator, and space (' ') as thousand separator.
This is achieved with this line :
<?php
$number = 1234.56;
// english notation (default)
$english_format_number = number_format($number);
// 1,235
// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56
$number = 1234.5678;
// english notation without thousands separator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57
?>
SEE ALSO money_format(3), sprintf(3), printf(3), sscanf(3).
PHP Documentation Group NUMBER_FORMAT(3)