I would like to pull a column from a file and place it in a variable:
The file would look like this:
N.Korea gibberish garbage
S.Korea gibberish garbage
USA gibberish garbage
Iraq gibberish garbage
Canada gibberish garbage
and items in the first... (8 Replies)
I have a pipe delimited flat file. I want to grep the records that are unique in the 4th field and repeat only once in the file
for e.g.. if the file contains this 3 records
i want to get the o/p as:
I just gave a sample here and the file is huge one and i cant just grep from the... (7 Replies)
Hi
I have file which contains 5 coulmns i need to add the fifth column value and put it in the desired location in the same column.
Here is the sample file..
ashop0004 SQL- 06/14/2009 06/14/2009 00:04:28 SUM
ashop0004 SQL- 06/14/2009 06/14/2009 00:00:37 ... (22 Replies)
So I have this input
1 10327 rs112750067 T C . PASS DP=65;AF=0.208;CB=BC,NCBI
1 10469 rs117577454 C G . PASS DP=2055;AF=0.020;CB=UM,BC,NCBI
1 10492 rs55998931 C T . PASS DP=231;AF=0.167;CB=BC,NCBI
1 10583 rs58108140 G A ... (3 Replies)
Hi Unix Experts,Team
I have a file (say comand_file.prm), The file has a command specified in column 6 (say "./execute_script.sh"). I want to execute this command in my script.
I am writing a KSH script to achieve this. Could you please assist me with this. (6 Replies)
Hola,
How can I add a column to a existing file??
PS: The column which should be added need to be the first column and it will be a parameter from the script.
Example:
1 name1
2 name2
3 name3
4 name3
Need to add parameter $file as a first column. $file is a file name with time... (6 Replies)
Dear all,
Lets say, I've a file a.txt containing two columns, like
a1 b1
.. ..
.. ..
and another file b.txt containg two columns, like
a1 c1
.. ..
.. ..
I need to put c1 column from b.txt file to the a.txt file. So, the output should be
a1 b1 c1
.. .. ..
.. ... (4 Replies)
Hi Team
I have file as below
empno,ename,sal
123,smith,1000
124,adams,2000
Required output: Using AWK
empno,ename,sal,deptno
123,smith,1000
124,adams,2000
Thanks,
Murali (5 Replies)
Hi,
I have 2 files.
file1 contains by lines: hash:salt:id
file2 contains by lines: username:hash:salt
I would like to add a new coloumn (id) form file1 to file2.
The new file should contains: username:hash:salt:id
Note: file1 contains less rows than file2.
I tried
paste -d':' file1... (12 Replies)
Discussion started by: freeroute
12 Replies
LEARN ABOUT PHP
array_column
ARRAY_COLUMN(3) 1 ARRAY_COLUMN(3)array_column - Return the values from a single column in the input arraySYNOPSIS
array array_column (array $array, mixed $column_key, [mixed $index_key = null])
DESCRIPTION array_column(3) returns the values from a single column of the $array, identified by the $column_key. Optionally, you may provide an
$index_key to index the values in the returned array by the values from the $index_key column in the input array.
PARAMETERS
o $array
- A multi-dimensional array (record set) from which to pull a column of values.
o $column_key
- The column of values to return. This value may be the integer key of the column you wish to retrieve, or it may be the string
key name for an associative array. It may also be NULL to return complete arrays (useful together with $index_key to reindex the
array).
o $index_key
- The column to use as the index/keys for the returned array. This value may be the integer key of the column, or it may be the
string key name.
RETURN VALUES
Returns an array of values representing a single column from the input array.
EXAMPLES
Example #1
Get column of first names from recordset
<?php
// Array representing a possible record set returned from a database
$records = array(
array(
'id' => 2135,
'first_name' => 'John',
'last_name' => 'Doe',
),
array(
'id' => 3245,
'first_name' => 'Sally',
'last_name' => 'Smith',
),
array(
'id' => 5342,
'first_name' => 'Jane',
'last_name' => 'Jones',
),
array(
'id' => 5623,
'first_name' => 'Peter',
'last_name' => 'Doe',
)
);
$first_names = array_column($records, 'first_name');
print_r($first_names);
?>
The above example will output:
Array
(
[0] => John
[1] => Sally
[2] => Jane
[3] => Peter
)
Example #2
Get column of last names from recordset, indexed by the "id" column
<?php
// Using the $records array from Example #1
$last_names = array_column($records, 'last_name', 'id');
print_r($last_names);
?>
The above example will output:
Array
(
[2135] => Doe
[3245] => Smith
[5342] => Jones
[5623] => Doe
)
PHP Documentation Group ARRAY_COLUMN(3)