Data from table to column


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Data from table to column
# 1  
Old 04-22-2010
Data from table to column

Hi All,
in bash I have a text file which is something like

Code:
  7.96634E-07 1.0000   0.00000E+00 0.0000   0.00000E+00 0.0000   1.59327E-06 0.7071
  2.23058E-05 0.1890   6.61207E-05 0.1098   1.13919E-04 0.0865   1.47377E-04 0.0747
....
....
  0.00000E+00 0.0000   0.00000E+00 0.0000   0.00000E+00 0.0000   0.00000E+00 0.0000
  1.01890E-03 0.0291   3.20088E-03 0.0172   5.45217E-03 0.0134   8.06035E-03 0.0111

Is there a way to read sequentially the data an put them in two columns. In the previous case it would be.

Code:
  7.96634E-07 1.0000
  0.00000E+00 0.0000
  0.00000E+00 0.0000
  1.59327E-06 0.7071
  2.23058E-05 0.1890
  6.61207E-05 0.1098
  1.13919E-04 0.0865
  1.47377E-04 0.0747
....
....

Thank you,
Sarah
# 2  
Old 04-22-2010
Code:
sed 's/[ ]\{3\}/\n/g' input_file

I have the input file with the following contents
Code:
7.96634E-07 1.0000   0.00000E+00 0.0000   0.00000E+00 0.0000   1.59327E-06 0.7071
2.23058E-05 0.1890   6.61207E-05 0.1098   1.13919E-04 0.0865   1.47377E-04 0.0747
0.00000E+00 0.0000   0.00000E+00 0.0000   0.00000E+00 0.0000   0.00000E+00 0.0000
1.01890E-03 0.0291   3.20088E-03 0.0172   5.45217E-03 0.0134   8.06035E-03 0.0111

When I am executing the above command I got the output as follows
Code:
7.96634E-07 1.0000
0.00000E+00 0.0000
0.00000E+00 0.0000
1.59327E-06 0.7071
2.23058E-05 0.1890
6.61207E-05 0.1098
1.13919E-04 0.0865
1.47377E-04 0.0747
0.00000E+00 0.0000
0.00000E+00 0.0000
0.00000E+00 0.0000
0.00000E+00 0.0000
1.01890E-03 0.0291
3.20088E-03 0.0172
5.45217E-03 0.0134
8.06035E-03 0.0111

# 3  
Old 04-22-2010
Try this,

Code:
sed -re "s/[ ]{2,}/\n/g" test_file

# 4  
Old 04-22-2010
Quote:
Originally Posted by Nila
Try this,

Code:
sed -re "s/[ ]{2,}/\n/g" test_file

Thank you, it works fine except that some times I have two \n probably because there is a new line in the original file.
Anyway to overcome this?

---------- Post updated at 03:14 AM ---------- Previous update was at 03:13 AM ----------

Quote:
Originally Posted by thillai_selvan
Code:
sed 's/[ ]\{3\}/\n/g' input_file

I have the input file with the following contents
Code:
7.96634E-07 1.0000   0.00000E+00 0.0000   0.00000E+00 0.0000   1.59327E-06 0.7071
2.23058E-05 0.1890   6.61207E-05 0.1098   1.13919E-04 0.0865   1.47377E-04 0.0747
0.00000E+00 0.0000   0.00000E+00 0.0000   0.00000E+00 0.0000   0.00000E+00 0.0000
1.01890E-03 0.0291   3.20088E-03 0.0172   5.45217E-03 0.0134   8.06035E-03 0.0111

When I am executing the above command I got the output as follows
Code:
7.96634E-07 1.0000
0.00000E+00 0.0000
0.00000E+00 0.0000
1.59327E-06 0.7071
2.23058E-05 0.1890
6.61207E-05 0.1098
1.13919E-04 0.0865
1.47377E-04 0.0747
0.00000E+00 0.0000
0.00000E+00 0.0000
0.00000E+00 0.0000
0.00000E+00 0.0000
1.01890E-03 0.0291
3.20088E-03 0.0172
5.45217E-03 0.0134
8.06035E-03 0.0111

It doesn't seems to work. The output is the same as the input. Thank you anyway,
# 5  
Old 04-23-2010
Try this,

Code:
sed -re "/^$/d; s/[ ]{2,}/\n/g"  test_file

# 6  
Old 04-23-2010
Try:
Code:
xargs -n 2 < infile

# 7  
Old 04-23-2010
The solution if scrutinizer does the job, not yet the one of Nila, but I found a solution. Thank you all,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change data in one column with data from another file's column

Hello, I have this file outputData: # cat /tmp/outputData __Capacity^6^NBSC01_Licences^L3_functionality_for_ESB_switch __Capacity^2100^NBSC01_Licences^Gb_over_IP __Capacity^1837^NBSC01_Licences^EDGE_BSS_Fnc __Capacity^1816^NBSC01_Licences^GPRS_CS3_and_CS4... (1 Reply)
Discussion started by: nypreH
1 Replies

2. Shell Programming and Scripting

Split column data if the table has n number of column's with some record

Split column data if the table has n number of column's with some record then how to split n number of colmn's line by line with records Table --------- Col1 col2 col3 col4 ....................col20 1 2 3 4 .................... 20 a b c d .................... v ... (11 Replies)
Discussion started by: Priti2277
11 Replies

3. Shell Programming and Scripting

Split column data if the table has n number of column's

please write a shell script Table -------------------------- 1 2 3 a b c 3 4 5 c d e 7 8 9 f g h Output should be like this --------------- 1 2 3 3 4 5 7 8 9 a b c c d e f g h (1 Reply)
Discussion started by: Priti2277
1 Replies

4. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

5. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

6. Shell Programming and Scripting

Construct 3 column table from one column list

Hi all! trying my best to parse a public site for information (ie fiscal year and turnover) about corporations. Doing this by having a file with business name and registration number (search key) the file bolag.txt currently looks like this Burgundy 556732-7217 AcademicSearch 556406-9879... (11 Replies)
Discussion started by: martindebruin
11 Replies

7. Shell Programming and Scripting

From column to table

Hi, I have an ascii file containing information. This file is n x m lines. Is there a way to generate an ascii file where the information is stored as n x m table instead? The m columns should be tab separated. Thanks a lot, Sarah (11 Replies)
Discussion started by: f_o_555
11 Replies

8. UNIX for Dummies Questions & Answers

average of a column in a table

Hello, Is there a quick way to compute the average of a column data in a numerical tab delimeted file? Thanks, Gussi (2 Replies)
Discussion started by: Gussifinknottle
2 Replies

9. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

10. Shell Programming and Scripting

file in to the column of the table

Hi I am ETL person. I have a table in Oracle having one of its column defined as BLOB where it can hold huge data. When i generate a file in DataStage and place it in a path. and i would like dump the file in to the column of the table having datatype as BLOB. (0 Replies)
Discussion started by: sant_leo
0 Replies
Login or Register to Ask a Question