Script to pivot flat file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script to pivot flat file
# 1  
Old 02-29-2012
Script to pivot flat file

Hi to all,
I have a file with a list of values:
v1,v2,v3....,v9

need file in this format:
Name1: v1
Name2: v2
Name3: v3
...
Name9: v9

Please help me out.

Last edited by mozi; 02-29-2012 at 10:31 PM..
# 2  
Old 02-29-2012
Code:
awk '{print "Name" NR ":" FS $0}' RS=',' yourfile

Code:
$ echo "a,b,c,d,e,f,g,h,i,j,k,l,m,n" | awk '{print "Name" NR ":" FS $0}' RS=','
Name1: a
Name2: b
Name3: c
Name4: d
Name5: e
Name6: f
Name7: g
Name8: h
Name9: i
Name10: j
Name11: k
Name12: l
Name13: m
Name14: n

This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 03-01-2012
ctsgnb,
thank you, but i mean that fields name are constant and set manually

Last edited by mozi; 03-01-2012 at 05:19 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pivot file using shellscript

Hi, I am new at using shell scripting. So I have a question for the more experienced Linux users. I would like to perform some kind of pivot on a file. Example Input file COL1,"2001-01-01","2001-03-01","2001-03-24" A1,22,,44 B1,56,78,12 C2,5,, I would like to have to following output... (2 Replies)
Discussion started by: shanlinux
2 Replies

2. Shell Programming and Scripting

awk Flat File Conversion Script

In awk how would I flatten input.txt to output.txt? Input: givenname: Darth sn: Vadar mail: d.vadar@deathstar.com uid: dv12345 orclguid: 1234567890 givenname: Carlito sn: Brigante mail: c.brigante@paradise.com uid: cb12345 orclguid: 2134567890 Output: ... (3 Replies)
Discussion started by: u20sr
3 Replies

3. Shell Programming and Scripting

Pivot file content

Hi All , I have a file as below . A "1" B "2" C "3" D "4" E "5" F "6" A "11" B "21" C "31" D "41" E "51" F "61" And the output should be like A B C D E F 1 2 3 4 5 6 11 21 31 41 51 (8 Replies)
Discussion started by: saj
8 Replies

4. Solaris

How to generate graph from flat file by using unix script

Hi, I need to generate graph from the text file in Unix server. The file contains the following data, Fri Feb 03 07:01:00 PST 2012|3325 Fri Feb 03 07:02:00 PST 2012|3349 Fri Feb 03 07:03:00 PST 2012|3290 Fri Feb 03 07:04:00 PST 2012|3496 Fri Feb 03 07:05:00 PST 2012|3362 Fri Feb 03 07:06:00... (2 Replies)
Discussion started by: gkn
2 Replies

5. Shell Programming and Scripting

Pivot script

Hi Please suggest a script that would do a horizontal pivot , on the fields separated by a semicolon Below is my input file 1|c2|aa 1|c3|dd 1|c4|cc 1|c5|aa 1|c6|ss 1|c7|dd 1|c8|bb 1|c9|jjj 1|c10|kkk 1|c11|fffg 1|c12|nnn;indi;pak;linf;wer 1|c13|lllnk;li;sdfsd;oiuo 1|c14|ppp... (5 Replies)
Discussion started by: mabarif16
5 Replies

6. Shell Programming and Scripting

Shell Script to Reformat a flat file

Hi , I have a text file noname.txt containing 1000+ records like this. One of the record I have given below. Input will b e like this BOT: 2010/06/01 00:25:59 21 = "private" Access-Method = 31 NCC = GBR 01 = "340806@osiris.fr.ft" 04 =... (2 Replies)
Discussion started by: smalya
2 Replies

7. Shell Programming and Scripting

Pivot file contents

Hi All, I am trying to pivot the contents in a file. Ex: I have a file sample.txt with data "A B C D", i need the contents to pivot & resulting file should look like "A B C ... (3 Replies)
Discussion started by: new_ds_man
3 Replies

8. UNIX for Dummies Questions & Answers

Verify a flat file with UNIX function or script.

I re-post my question to seek your help and critique. I was required to verify a very large and tab-delimited file, named 'MyFile'. 1. The each line in 'MyFile' has 7 columns, and that the values in the 5th column are integers. I need to use shell functions (and standard LINUX/UNIX filters) to... (1 Reply)
Discussion started by: duke0001
1 Replies

9. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

10. Shell Programming and Scripting

Converting Pivot file to flat file

I have a file in this format. P1 P2 P3......................... A001 v11 v21 v31...................... A002 v12 v22 v32............................ A003 v13 v23 v33.......................... A004 v14 v24 v34.............................. . . . A00n... (2 Replies)
Discussion started by: vskr72
2 Replies
Login or Register to Ask a Question