Sponsored Content
Top Forums Shell Programming and Scripting Transpose multiple rows (with a mix of space and enter) to a single column Post 302837405 by sara.nowreen on Thursday 25th of July 2013 05:01:00 PM
Old 07-25-2013
Transpose multiple rows (with a mix of space and enter) to a single column

How to change the uploaded weekly file data to the following format?
Code:
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
BAG001,PT006,BARGUNA,AMTALI,1/16/1978,1.98,2.29,Piezometer,220825,901430
BAG001,PT006,BARGUNA,AMTALI,1/23/1978,2.03,2.29,Piezometer,220825,901430
BAG001,PT006,BARGUNA,AMTALI,1/30/1978,2.03,2.29,Piezometer,220825,901430

Input file:
Code:
                      GROUNDWATER CIRCLE-2,EDPCELL,BWDB
                  Depth to Watertable from Measuring Point
                     Measuring Frequency Monday 0600 hrs
               End Year 88.88 Missing Data 99.99 Unit in metre
New Well_Id :  BAG001       Old Well_Id :  PT006      
District    :  BARGUNA            Thana :  AMTALI             
No. of Change  1
Well Type   Date      Village            Lati.   Longi.   R.L    P.H   Depth 
Piezometer  11.12.77  Amtali             220825  901430    2.29  0.46   8.53
Piezometer  30.12.85  Amtali             220825  901430    2.29  0.46  23.47
------------------------------------------------------------------------------
Yr. 1978  St. Date Jan 02
  1.81  1.87  1.98  2.03  2.03  2.11  2.16  2.14  2.16  2.24  2.29  2.39  2.34
  2.24  2.26  2.14  2.21  2.24  2.14  1.88  1.68  1.47  1.42  1.53  1.50  1.20
  1.20  1.17  1.12  1.14  1.14  1.17  1.12  1.14  0.99  1.17  1.42  1.45  1.40
  1.32  1.42  1.45  1.47  1.53  1.50  1.53  1.47  1.53  1.63  1.60 99.99 99.99
 88.88
Yr. 1979  St. Date Jan 01
  1.70  1.73  1.98  1.96  1.98  2.01  2.01  1.93  1.88  1.85  1.85  1.83  1.91
  1.85  1.83  1.81  1.78  1.73  1.68  1.73  1.73  1.63  1.65  1.60  1.68  1.63
  1.60  1.55  1.50  1.58  1.53  1.32  1.22  1.14  1.14  1.22  1.45  1.42  1.45
  1.40  1.42  1.45  1.53  1.58  1.53  1.73  1.63  1.65  1.70  1.75  1.63  1.75
  1.75 88.88


Last edited by Scott; 07-25-2013 at 06:42 PM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting Single Column into Multiple rows

i have single column which is starting with same string(many number of rows) i have to convert each into a single row.how can i do that? laknar std mes 23 55 laknar isd phone no address amount 99 I have to convert above like below. laknar|std|mes|23|55 laknar|isd|phone... (3 Replies)
Discussion started by: laknar
3 Replies

2. Shell Programming and Scripting

Single column into multiple rows

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

3. Shell Programming and Scripting

awk transpose rows to column

Need to transpose in awk rows to column like this: input: A1,6,5,4 3,2,1, A2,8,7,9,10,11,12,13,14 A3,1,2,3,5,7,8,9 A4,9,4,8,1,5,3, output: A1,1 A1,2 A1,4 ... A2,7 A2,8 ... A3,1 A3,2 ... A4,1 A4,3 (5 Replies)
Discussion started by: sdf
5 Replies

4. Shell Programming and Scripting

How to merge multiple rows into single row if first column matches ?

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

[SOLVED] splitting a single column(with spaces) into multiple rows

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

Converting Single Column into Multiple rows, but with strings to specific tab column

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

7. Shell Programming and Scripting

Convert single column into multiple rows

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

8. Shell Programming and Scripting

Converting Single Column into Multiple rows

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

9. Programming

To transpose rows to column in hadoop

Hi, i am having an HDFS file which is comma seperated, i need to transpose from rows to column only the header columns text.csv cnt,name,place 1,hi,nz 2,hello,aus I need cnt, name, place while using below command in hadoop getting the error hadoop fs -fmt -1 text.csv (0 Replies)
Discussion started by: rohit_shinez
0 Replies

10. UNIX for Beginners Questions & Answers

How to transpose pieces of data in a column to multiple rows?

Hello Everyone, I am very new to the world of regular expressions. I am trying to use grep/sed for the following: Input file is something like this and there are multiple such files: abc 1 2 3 4 5 ***END*** abc 6 7 8 9 ***END*** abc 10 (2 Replies)
Discussion started by: shellnewuser
2 Replies
Data::Random(3pm)					User Contributed Perl Documentation					 Data::Random(3pm)

NAME
Data::Random - Perl module to generate random data SYNOPSIS
use Data::Random qw(:all); my @random_words = rand_words( size => 10 ); my @random_chars = rand_chars( set => 'all', min => 5, max => 8 ); my @random_set = rand_set( set => @set, size => 5 ); my $random_enum = rand_enum( set => @set ); my $random_date = rand_date(); my $random_time = rand_time(); my $random_datetime = rand_datetime(); open(FILE, ">rand_image.png") or die $!; binmode(FILE); print FILE rand_image( bgcolor => [0, 0, 0] ); close(FILE); DESCRIPTION
A module used to generate random data. Useful mostly for test programs. METHODS
rand_words() This returns a list of random words given a wordlist. See below for possible parameters. o wordlist - the path to the wordlist file. On Debian systems one can be found at /usr/share/dict/words. You can also optionally supply a Data::Random::WordList object to keep a persistent wordlist. The default is the wordlist distributed with this module. o min - the minimum number of words to return. The default is 1. o max - the maximum number of words to return. The default is 1. o size - the number of words to return. The default is 1. If you supply a value for 'size', then 'min' and 'max' aren't paid attention to. o shuffle - whether or not the words should be randomly shuffled. Set this to 0 if you don't want the words shuffled. The default is 1. Random::Data::WordList returns words in the order that they're viewed in the word list file, so shuffling will make sure that the results are a little more random. rand_chars() This returns a list of random characters given a set of characters. See below for possible parameters. o set - the set of characters to be used. This value can be either a reference to an array of strings, or one of the following: alpha - alphabetic characters: a-z, A-Z upperalpha - upper case alphabetic characters: A-Z loweralpha - lower case alphabetic characters: a-z numeric - numeric characters: 0-9 alphanumeric - alphanumeric characters: a-z, A-Z, 0-9 char - non-alphanumeric characters: # ~ ! @ $ % ^ & * ( ) _ + = - { } | : " < > ? / . ' ; ] [ ` all - all of the above o min - the minimum number of characters to return. The default is 0. o max - the maximum number of characters to return. The default is the size of the set. o size - the number of characters to return. The default is 1. If you supply a value for 'size', then 'min' and 'max' aren't paid attention to. o shuffle - whether or not the characters should be randomly shuffled. Set this to 0 if you want the characters to stay in the order received. The default is 1. rand_set() This returns a random set of elements given an initial set. See below for possible parameters. o set - the set of strings to be used. This should be a reference to an array of strings. o min - the minimum number of strings to return. The default is 0. o max - the maximum number of strings to return. The default is the size of the set. o size - the number of strings to return. The default is 1. If you supply a value for 'size', then 'min' and 'max' aren't paid attention to. o shuffle - whether or not the strings should be randomly shuffled. Set this to 0 if you want the strings to stay in the order received. The default is 1. rand_enum() This returns a random element given an initial set. See below for possible parameters. o set - the set of strings to be used. This should be a reference to an array of strings. rand_date() This returns a random date in the form "YYYY-MM-DD". 2-digit years are not currently supported. Efforts are made to make sure you're returned a truly valid date - ie, you'll never be returned the date February 31st. See the options below to find out how to control the date range. Here are a few examples: # returns a date somewhere in between the current date, and one year from the current date $date = rand_date(); # returns a date somewhere in between September 21, 1978 and September 21, 1979 $date = rand_date( min => '1978-9-21' ); # returns a date somewhere in between September 21, 1978 and the current date $date = rand_date( min => '1978-9-21', max => 'now' ); # returns a date somewhere in between the current date and September 21, 2008 $date = rand_date( min => 'now', max => '2008-9-21' ); See below for possible parameters. o min - the minimum date to be returned. It should be in the form "YYYY-MM-DD" or you can alternatively use the string "now" to represent the current date. The default is the current date; o max - the maximum date to be returned. It should be in the form "YYYY-MM-DD" or you can alternatively use the string "now" to represent the current date. The default is one year from the minimum date; rand_time() This returns a random time in the form "HH:MM:SS". 24 hour times are supported. See the options below to find out how to control the time range. Here are a few examples: # returns a random 24-hr time (between 00:00:00 and 23:59:59) $time = rand_time(); # returns a time somewhere in between 04:00:00 and the end of the day $time = rand_time( min => '4:0:0' ); # returns a time somewhere in between 8:00:00 and the current time (if it's after 8:00) $time = rand_time( min => '12:00:00', max => 'now' ); # returns a date somewhere in between the current time and the end of the day $time = rand_time( min => 'now' ); See below for possible parameters. o min - the minimum time to be returned. It should be in the form "HH:MM:SS" or you can alternatively use the string "now" to represent the current time. The default is 00:00:00; o max - the maximum time to be returned. It should be in the form "HH:MM:SS" or you can alternatively use the string "now" to represent the current time. The default is 23:59:59; rand_datetime() This returns a random date and time in the form "YYYY-MM-DD HH:MM:SS". See the options below to find out how to control the date/time range. Here are a few examples: # returns a date somewhere in between the current date/time, and one year from the current date/time $datetime = rand_datetime(); # returns a date somewhere in between 4:00 September 21, 1978 and 4:00 September 21, 1979 $datetime = rand_datetime( min => '1978-9-21 4:0:0' ); # returns a date somewhere in between 4:00 September 21, 1978 and the current date $datetime = rand_datetime( min => '1978-9-21 4:0:0', max => 'now' ); # returns a date somewhere in between the current date/time and the end of the day September 21, 2008 $datetime = rand_datetime( min => 'now', max => '2008-9-21 23:59:59' ); See below for possible parameters. o min - the minimum date/time to be returned. It should be in the form "YYYY-MM-DD HH:MM:SS" or you can alternatively use the string "now" to represent the current date/time. The default is the current date/time; o max - the maximum date/time to be returned. It should be in the form "YYYY-MM-DD HH:MM:SS" or you can alternatively use the string "now" to represent the current date/time. The default is one year from the minimum date/time; rand_image() This returns a random image. Currently only PNG images are supported. See below for possible parameters. o minwidth - the minimum width of the image. The default is 1. o maxwidth - the maximum width of the image. The default is 100. o width - the width of the image. If you supply a value for 'width', then 'minwidth' and 'maxwidth' aren't paid attention to. o minheight - the minimum height of the image. The default is 1. o maxheight - the maximum height of the image. The default is 100. o height - the height of the image. If you supply a value for 'width', then 'minwidth' and 'maxwidth' aren't paid attention to. o minpixels - the minimum number of random pixels to display on the image. The default is 0. o maxpixels - the maximum number of random pixels to display on the image. The default is width * height. o pixels - the number of random pixels to display on the image. If you supply a value for 'pixels', then 'minpixels' and 'maxpixels' aren't paid attention to. o bgcolor - the background color of the image. The value must be a reference to an RGB array where each element is an integer between 0 and 255 (eg. [ 55, 120, 255 ]). o fgcolor - the foreground color of the image. The value must be a reference to an RGB array where each element is an integer between 0 and 255 (eg. [ 55, 120, 255 ]). VERSION
0.07 AUTHOR
Originally written by: Adekunle Olonoh Currently maintained by: Buddy Burden (barefoot@cpan.org), starting with version 0.06 CREDITS
Hiroki Chalfant David Sarno COPYRIGHT
Copyright (c) 2000-2011 Adekunle Olonoh. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Data::Random::WordList perl v5.14.2 2012-06-04 Data::Random(3pm)
All times are GMT -4. The time now is 06:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy