Convert a horizontal lines to vertical lines in a csv file


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Convert a horizontal lines to vertical lines in a csv file
# 1  
Old 09-26-2019
Convert a horizontal lines to vertical lines in a csv file

Hi..
I need some help in converting the below horizontal lines to vertical lines format.
can anyone help me on this.

input file
Code:
 Hour,1,2,3,4,5
 90RT,106,111,111,112,111

output file
Code:
Hour,90RT
1,106
2,111
3,111
4,112
5,111


Last edited by Raghuram717; 09-26-2019 at 03:45 AM..
# 2  
Old 09-26-2019
Did you consider searching these fora? Solutions to similar problems have been posted umpteen times...
Try

Code:
awk -F, '
        {for (i=1; i<=NF; i++) C[i] = C[i] "," $i
        }
END     {for (i=1; i<=NF; i++) print substr(C[i],2)
        }
' file

# 3  
Old 09-26-2019
i have searched but could find vertical to horizontal that too with single line data.
so posted the question at last.
Thanks Rudic ..above one worked like a charm
# 4  
Old 09-26-2019
Also try:
Code:
tr , '\n' < file | pr -2ts,

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do i do the vertical to horizontal??

51009 8746 8912 17986 20315 24998 5368 38934 7805 8566 (4 Replies)
Discussion started by: nikhil jain
4 Replies

2. Shell Programming and Scripting

Need perl or shell script to sort vertical lines to horizontal line in csv format

Need perl or shell script to sort vertical lines to horizontal line in csv format My file like below ------------------------- ================================================================================ PATH PINKY1000#I1-1-ZENTA1000-2#I7-1-ASON-SBR-UP-943113845 ... (4 Replies)
Discussion started by: sreedhargouda.h
4 Replies

3. Shell Programming and Scripting

Vertical And Horizontal Pivoting

Hi All, My Input data is: A=1 B=2 My desired Output should be: A|B 1|2 Thanks in advance... (3 Replies)
Discussion started by: kmsekhar
3 Replies

4. Shell Programming and Scripting

change log vertical to horizontal lines

Hi, Need help unix command to change this : become this Anyone can help me?:wall: (2 Replies)
Discussion started by: justbow
2 Replies

5. UNIX for Dummies Questions & Answers

vertical to horizontal

dear all, i'm new to unix and i try to figure out the best case for making list of vertical text to become horizontal and skip the line 1 and 2. example text : Data DATE XXXXX MAX 47 53 49 51 48 48 7 46 51 8 25 (6 Replies)
Discussion started by: andrisetia
6 Replies

6. UNIX for Dummies Questions & Answers

Horizontal to vertical

Hi, Silly question, if I have an excel file that looks something like this: ................. Subject 1 Subject 2 Subject 3 Subject 4 Fever..............13...........9.............23..........14 Headache.........2............12...........18..........23... (3 Replies)
Discussion started by: Xterra
3 Replies

7. Shell Programming and Scripting

Need help in changing vertical lines to horizontal line in a file

Hi, I have a file like below robert PREF: 3 AVAIL: henry PREF: 234 AVAIL: john PREF: 145,178 AVAIL: 123 matt PREF: 564,932 AVAIL: ten PREF: 389 AVAIL: kill (2 Replies)
Discussion started by: rocky1954
2 Replies

8. UNIX for Dummies Questions & Answers

Delete vertical lines in an text file

Hi everybody! I need to delete several vertical lines in a huge text file. It should work like the example below. Delete the vertical lines 2 and 8. 123456789 masldfjla afsajfwel sajfljsaf safsarfrl sajfeljwq 1345679 msldfja asajfwl sjfljsf sfsarfl sjfeljq Is there a... (11 Replies)
Discussion started by: relaxo
11 Replies

9. Linux

Horizontal Lines

Jan 18, 2010 14:15:31 GMT Hello, I get horizontal black lines after each line of text and every blank line is colored black. I am using HP Color LaserJet... (5 Replies)
Discussion started by: H_P
5 Replies

10. UNIX for Advanced & Expert Users

Horizontal sorting of lines in a File: SED implementation?

Hi guys, Do you know how can I sort a file horizontally per line??? sample input file: zebra papa dog apple yahoo kangaroo ape sample output: apple dog papa zebra ape kangaroo yahoo Please post if u know the sed implementation of this (or whatever implementation u may know of)... (7 Replies)
Discussion started by: marlonus999
7 Replies
Login or Register to Ask a Question