Hi All,
I have the following code sequence for reading some bulk file and moving the content to two different arrays.
while read data
do
THREEG_PATTERN=`echo $data | egrep "3G"`
if
then
NEW_THREEG_PATTERN=`echo $THREEG_PATTERN | cut -d " " -f2`
... (12 Replies)
Hi,
can I use array elements ( all ) in conditional statements?
the problem is ,the total number of elements is not known.
e.g
A is an array with elements - 1,2,3
now if i want to test if the 1 st field of input record is either 1,2 or 3, i can do something like this
if ( $1 ~... (1 Reply)
Hi all,
i have a data array as follows.
array=ertfgj2345
array=456ttygkd
.
.
.
array=errdjt3235
so number or elements in the array can varies depending on how big the data input is.
now i have a variable, and it is $1 (there are $2, $3 and so on, i am only interested in $1).
... (9 Replies)
I have the following in an awk script. I want to do them on condition that: fext == "xt"
FNR == NR {
/>/ && idx = ++i
$2 || val = $1
next
}
FNR in idx { v = val] }
{ !/>/ && srdist = abs($1 - v) }
/>/ || NF == 2 && srdist < dsrmx {... (1 Reply)
I have the following awk script and I want to change it to be inside a condition for the file extension.
################################################################################
# abs: Returns the absolute value of a number
function abs(val) {
return val > 0 ? val \
... (4 Replies)
Hello I have the file df.tmp
FS is actually the / FS but escape character\ and end of line $ is used in order to fetch exctly / and not other filesystems.
awk '/\/$/ {print $(NF-1)+0}' df.tmp will work properly and return a value eg. 60
but when I am trying to issue the command with the array... (3 Replies)
I would like to have help with syntax for using a string varaibles inside if and else in a awk one liner.
Eg. I would like to say, list all the filenames that have been modified in a particular month(present in a string variable) or list all the filenames whose owner is $owns and owner group is... (3 Replies)
Hi ,
Please excuse me for opening a new thread i am unable to find out the syntax error
in my if else condition inside for loop in awk command ,
my actual aim is to print formatted html td tag when if condition (True) having string as "failed",
could anyone please advise what is the right... (2 Replies)
Hi.
I wrote this small bash script, i want to compare second column from file1 with file2 if a pattern matches. Files are small and I am sure that pattern occurs only once. I think this can be rewritten into a awk one liner. Appreciate if someone could give me idea. Whole NR FNR confuse me :o
... (6 Replies)
Discussion started by: ctrld
6 Replies
LEARN ABOUT PHP
splfileobject.fputcsv
SPLFILEOBJECT.FPUTCSV(3) 1 SPLFILEOBJECT.FPUTCSV(3)SplFileObject::fputcsv - Write a field array as a CSV line
SYNOPSIS
public int SplFileObject::fputcsv (array $fields, [string $delimiter = ","], [string $enclosure = '"'], [string $escape = "
DESCRIPTION
Writes the $fields array to the file as a CSV line.
PARAMETERS
o $fields
- An array of values.
o $delimiter
- The optional $delimiter parameter sets the field delimiter (one character only).
o $enclosure
- The optional $enclosure parameter sets the field enclosure (one character only).
o $escape
- The optional $escape parameter sets the escape character (one character only).
RETURN VALUES
Returns the length of the written string or FALSE on failure.
Returns FALSE, and does not write the CSV line to the file, if the $delimiter or $enclosure parameter is not a single character.
ERRORS /EXCEPTIONS
An E_WARNING level error is issued if the $delimiter or $enclosure parameter is not a single character.
CHANGELOG
+--------------+-------------------------------+
| Version | |
| | |
| | Description |
| | |
+--------------+-------------------------------+
|5.5.21, 5.6.5 | |
| | |
| | Added the $escape parameter. |
| | |
+--------------+-------------------------------+
EXAMPLES
Example #1
SplFileObject::fputcsv example
<?php
$list = array (
array('aaa', 'bbb', 'ccc', 'dddd'),
array('123', '456', '789'),
array('"aaa"', '"bbb"')
);
$file = new SplFileObject('file.csv', 'w');
foreach ($list as $fields) {
$file->fputcsv($fields);
}
?>
The above example will write the following to file.csv:
aaa,bbb,ccc,dddd
123,456,789
"""aaa""","""bbb"""
SEE ALSO fputcsv(3), SplFileObject::fgetcsv.
PHP Documentation Group SPLFILEOBJECT.FPUTCSV(3)