Is there anyway to use awk to add a first column to my data that automatically goes from 1 to n , where n is the numbers of my rows?:confused: (4 Replies)
How do you delete cells from a space delimited text file given row and column number? Letś say the row number is r and the column number is c. Thanks! (5 Replies)
Hi Friends,
I have a single column data like below.
1
2
3
4
5
I need the output like below.
0
1
2
3
4
where each row (including first row) subtracting from first row and the result should print below like the way shown in output file.
Thanks
Sid (11 Replies)
Hi,
I would like to add a new column containing the row numbers to a text file. How do I go about doing that? Thanks!
Example input:
A X
B Y
C D
Output:
A X 1
B Y 2
C D 3 (5 Replies)
Hi Gurus,
I have an I/P file which looks like
100 1
200 1
300 4
100 2
200 3
300 4
100 9
200 8
300 7
I would liek to get O/P as
100 200 300
1 1 4
2 3 4 (8 Replies)
Hi,
i have a raw output file like this
167,63.50
167,63.50
168,63.68
166,63.68
168,63.68
I would like to add every each N rows (for example 60) and in a third column , a timestamp using the command date +"%H:%M"how can i do it with one single command ?
Thank you !! (5 Replies)
Hi everyone..
I have a list of values in a file...
a,
b,
c,
1,
2,
3,
aaaa,
bbbbb,
I am interested in converting this column to a row..
"text",aaaa,
bbbb
a,1 (7 Replies)
Hi,
I have a comma separated file. I would like to print every alternate columns into a new row.
Example input file:
Name : John, Age : 30, DOB : 30-Oct-2018
Example output:
Name,Age,DOB
John,30,30-Oct-2018 (3 Replies)
Discussion started by: Lini
3 Replies
LEARN ABOUT PHP
db2_fetch_both
DB2_FETCH_BOTH(3) 1 DB2_FETCH_BOTH(3)db2_fetch_both - Returns an array, indexed by both column name and position, representing a row in a result setSYNOPSIS
array db2_fetch_both (resource $stmt, [int $row_number = -1])
DESCRIPTION
Returns an array, indexed by both column name and position, representing a row in a result set. Note that the row returned by
db2_fetch_both(3) requires more memory than the single-indexed arrays returned by db2_fetch_assoc(3) or db2_fetch_array(3).
PARAMETERS
o $stmt
- A valid stmt resource containing a result set.
o $row_number
- Requests a specific 1-indexed row from the result set. Passing this parameter results in a PHP warning if the result set uses a
forward-only cursor.
RETURN VALUES
Returns an associative array with column values indexed by both the column name and 0-indexed column number. The array represents the next
or requested row in the result set. Returns FALSE if there are no rows left in the result set, or if the row requested by $row_number does
not exist in the result set.
EXAMPLES
Example #1
Iterating through a forward-only cursor
If you call db2_fetch_both(3) without a specific row number, it automatically retrieves the next row in the result set. The follow-
ing example accesses columns in the returned array by both column name and by numeric index.
<?php
$sql = "SELECT id, name, breed, weight FROM animals ORDER BY breed";
$stmt = db2_prepare($conn, $sql);
$result = db2_execute($stmt);
while ($row = db2_fetch_both($stmt)) {
printf ("%-5d %-16s %-32s %10s
",
$row['ID'], $row[0], $row['BREED'], $row[3]);
}
?>
The above example will output:
0 Pook cat 3.20
5 Rickety Ride goat 9.70
2 Smarty horse 350.00
Example #2
Retrieving specific rows with db2_fetch_both(3) from a scrollable cursor
If your result set uses a scrollable cursor, you can call db2_fetch_both(3) with a specific row number. The following example
retrieves every other row in the result set, starting with the second row.
<?php
$sql = "SELECT id, name, breed, weight FROM animals ORDER BY breed";
$result = db2_exec($stmt, $sql, array('cursor' => DB2_SCROLLABLE));
$i=2;
while ($row = db2_fetch_both($result, $i)) {
printf ("%-5d %-16s %-32s %10s
",
$row[0], $row['NAME'], $row[2], $row['WEIGHT']);
$i = $i + 2;
}
?>
The above example will output:
0 Pook cat 3.20
5 Rickety Ride goat 9.70
2 Smarty horse 350.00
SEE ALSO db2_fetch_array(3), db2_fetch_assoc(3), db2_fetch_object(3), db2_fetch_row(3), db2_result(3).
PHP Documentation Group DB2_FETCH_BOTH(3)