![]() |
|
|
google unix.com
|
|||||||
| Forums | Casino | Register | Forum Rules | Links | Albums | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| New to scripting, Need help | newbie22102 | Shell Programming and Scripting | 2 | 02-25-2008 10:08 AM |
| scripting help | james94538 | Shell Programming and Scripting | 2 | 02-08-2008 06:36 PM |
| difference between AIX shell scripting and Unix shell scripting. | haroonec | Shell Programming and Scripting | 2 | 04-12-2006 08:12 AM |
| scripting guru's pls help me with scripting on AIX | thatiprashant | Shell Programming and Scripting | 1 | 01-20-2006 06:58 PM |
| KSH Scripting | dstaller | Shell Programming and Scripting | 1 | 11-16-2005 01:30 PM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|||
|
Need scripting Help
Dear Scripting experts,
Request to guide me in moving column values to rows Example: File 1: 1,a,b,c,d,e,f,g,h 2,f,g,h,i,l Output file 1,a,b,c 1,d,e,f 1,g,h 2,f,g,h 2,i,l Actually I tried with using awk and sed but unfortunately i couldn't get the resultant. Regards nani |
| Sponsored Links |
|
|||
|
Here's a fairly simple Python approach (tested and working).
Code:
$ cat nani123.py
#!/usr/bin/env python
input = open("temp.txt", 'r')
for line in input:
line = line.rstrip()
line = line.split(',')
num = line[0]
data = line[1:]
while data:
print num + "," + ','.join(data[:3])
data = data[3:]
Code:
$ cat temp.txt 1,a,b,c,d,e,f,g,h 2,f,g,h,i,l $ python nani123.py 1,a,b,c 1,d,e,f 1,g,h 2,f,g,h 2,i,l |
|
||||
|
Quote:
|
||||
| Google The UNIX and Linux Forums |
![]() |
| Bookmarks |
| Tags |
| None |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|