01-23-2009
I checked the script it just adding pipe before the each line.
shall i try this script
file=/path/to/inputfile
numcols=1 ## adjust to taste
n=1
IFS='
'
while [ $n -le $numcols ]
do
{
printf "%s," $( cut -f "$n" "$file" )
echo
} > file_col$n
n=$(( $n + 1 ))
done
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all,
I need to convert this file having just one column into two column file
current file:
a
15
b
21
c
34
d
48
e
10
wanted:
a 15
b 21
c 34 (15 Replies)
Discussion started by: prachiagra
15 Replies
2. UNIX for Advanced & Expert Users
Hi all I have a file as below :
Development
System
User
Production
i want to convert the file to below format:
"Development","System","User","Production"
Is it possible with UNIX ? if so can you please give me some direction on it ?
Thanks,
Satya
Use code tags please, ty. (10 Replies)
Discussion started by: satyaranjon
10 Replies
3. Shell Programming and Scripting
Can somebody help me in solving this..
Input data is like
0 A
1 B
2 C
3 D
0 A1
1 B1
2 C1
3 D1
0 A2
1 B2
2 C2
3 D2
Output should be like
A B C D
A1 B1 C1 D1
A2 B2 C2 D2 (7 Replies)
Discussion started by: Mahantesh Patil
7 Replies
4. Shell Programming and Scripting
Hi,
Can anyone suggest quick way to get desired output?
Sample input file content:
A 12 9
A -0.3 2.3
B 1.0 -4
C 34 1000
C -111 900
C 99 0.09
Output required:
A 12 9 -0.3 2.3
B 1.0 -4
C 34 1000 -111 900 99 0.09
Thanks (3 Replies)
Discussion started by: cbm_000
3 Replies
5. UNIX for Dummies Questions & Answers
Hi All,
My requisite is to split a single column of phonemes seperated by spaces into multiple rows.
my input file is:
a
dh
u
th
a
qn
ch
A
v
U
r
k
my o/p should be like:
adhu a dh u (3 Replies)
Discussion started by: girlofgenuine
3 Replies
6. Shell Programming and Scripting
How to change the uploaded weekly file data to the following format?
New Well_Id,Old Well_Id,District,Thana,Date,Data,R.L,WellType,Lati.,Longi.
BAG001,PT006,BARGUNA,AMTALI,1/2/1978,1.81,2.29,Piezometer,220825,901430
BAG001,PT006,BARGUNA,AMTALI,1/9/1978,1.87,2.29,Piezometer,220825,901430... (3 Replies)
Discussion started by: sara.nowreen
3 Replies
7. Shell Programming and Scripting
Dear fellows, I need your help.
I'm trying to write a script to convert a single column into multiple rows.
But it need to recognize the beginning of the string and set it to its specific Column number.
Each Line (loop) begins with digit (RANGE).
At this moment it's kind of working, but it... (6 Replies)
Discussion started by: AK47
6 Replies
8. Shell Programming and Scripting
Convert Single column to multiple rows
file a.txt contains data like below
Server=abc
Run=1
Tables=10
Sessions=16
Time=380
Jobs=5
Server=abc
Run=2
Tables=15
Sessions=16
Time=400
Jobs=5
Server=abc
Run=3
Tables=20
Sessions=16
Time=450 (5 Replies)
Discussion started by: sol_nov
5 Replies
9. Shell Programming and Scripting
Hi,
I want to convert a single row values to multiple rows, but the no. of rows are not fixed.
For example, I have a row as below
abc-def-lmn-mno-xyz
out put should be
get abc
get def
get lmn
get xyz (4 Replies)
Discussion started by: Suneel Mekala
4 Replies
10. Shell Programming and Scripting
Hi .. anyone can you help me ?
i need to convert text below into multiple columns
interface; GigabitEthernet0/0/0/0
description; TRUNK_PE-D2-JT2-VPN_Gi0/0/0/0_TO_ME4-A-JKT-JT_4/1/1_1G
mtu 9212
negotiation auto
interface; GigabitEthernet0/0/0/0.11
description; tes
encapsulation;... (1 Reply)
Discussion started by: mad3linux
1 Replies
LEARN ABOUT PHP
pdostatement.fetchcolumn
PDOSTATEMENT.FETCHCOLUMN(3) 1 PDOSTATEMENT.FETCHCOLUMN(3)
PDOStatement::fetchColumn - Returns a single column from the next row of a result set
SYNOPSIS
public mixed PDOStatement::fetchColumn ([int $column_number])
DESCRIPTION
Returns a single column from the next row of a result set or FALSE if there are no more rows.
Note
PDOStatement.fetchColumn(3) should not be used to retrieve boolean columns, as it is impossible to distinguish a value of FALSE from
there being no more rows to retrieve. Use PDOStatement.fetch(3) instead.
PARAMETERS
o $column_number
- 0-indexed number of the column you wish to retrieve from the row. If no value is supplied, PDOStatement.fetchColumn(3) fetches
the first column.
RETURN VALUES
PDOStatement.fetchColumn(3) returns a single column in the next row of a result set.
Warning
There is no way to return another column from the same row if you use PDOStatement.fetchColumn(3) to retrieve data.
EXAMPLES
Example #1
Return first column of the next row
<?php
$sth = $dbh->prepare("SELECT name, colour FROM fruit");
$sth->execute();
print("Fetch the first column from the first row in the result set:
");
$result = $sth->fetchColumn();
print("name = $result
");
print("Fetch the second column from the second row in the result set:
");
$result = $sth->fetchColumn(1);
print("colour = $result
");
?>
The above example will output:
Fetch the first column from the first row in the result set:
name = lemon
Fetch the second column from the second row in the result set:
colour = red
SEE ALSO
PDO.query(3), PDOStatement.fetch(3), PDOStatement.fetchAll(3), PDO.prepare(3), PDOStatement.setFetchMode(3).
PHP Documentation Group PDOSTATEMENT.FETCHCOLUMN(3)