Sponsored Content
Full Discussion: Split columns into rows
Top Forums Shell Programming and Scripting Split columns into rows Post 302969830 by syd on Tuesday 29th of March 2016 01:41:41 AM
Old 03-29-2016
PFb sample data

Input file
Code:
10000|1442000000:[-99]|latChangeDate:1400|latest:-99
10001|1446:[-99]|latChangeDate:144385400|latest:351592174|1448400:[35374]
10002|1424:[38006],latChangeDate:144246|latest:355746
10003
10004|14424:[358386]|latChangeDate:14425200|latest:35872386
10005|14480:[351435]|latest:351935

Output I should get is
Code:
ID|latChangeDate|latest
10000|1400|-99
10001|144385400|351592174
10002|144246|355746
10003|XXXX|XXXX
10004|14425200|35872386
10005|XXXX|351935

I have used code
Code:
sed -i 's/"//g' input.txt
printf "ID|latChangeDate|latest\n" >> output1.csv
while read -r line
do
id=`echo $line | grep -o '^[0-9]\+'`
printf "$id|"
if [[ $line =~ latChangeDate ]]
then
lt_cre=`echo $line | grep -o 'latChangeDate:\w\+'`
lt_cre_val=`echo $lt_cre | cut -d: -f2`
printf "${lt_cre_val}|"
else
printf "XXXXXXXXX|"
fi
if [[ $line =~ latest ]]
then
lt_cre_ac_dt=`echo $line | grep -o 'latest:\w\+'`
lt_cre_ac_dt_val=`echo $lt_cre_ac_dt | cut -d: -f2`
printf "${lt_cre_ac_dt_val}\n"
else
printf "XXXXXXXXX\n"
fi
done < /input.txt

for above script iam getting output as
Code:
ID|latChangeDate|latest
10000|1400|
10001|144385400|351592174
10002|144246|355746
10003|XXXX|XXXX
10004|14425200|35872386
10005|XXXX|351935

iam not getting negative value -99.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

split rows

Hi I wanted to split rows based on the number of 1's present in 21st field(21st field is 40 length field) so I wrote the below awk code. However, the tool that I am using to invoke the command is not recognising the command. So, could you please help me to translate this command to sed? awk... (5 Replies)
Discussion started by: ahmedwaseem2000
5 Replies

2. Shell Programming and Scripting

Split rows

Hi all, I need a simple bin/sh script FILE1: ab1 gegege swgdeyedg ac2 jxjjxjxjxxjxjx ad3 ae4 xjxjxj zhzhzh ahahs af5 sjsjsjs ssjsjsjsj sjsjsj ag6 shshshshs sjjssj shhshshs myScript.sh has to return: ROW ab1 ROW ac2 ROW ad3 ROW ae4 In other words: "ROW " + the first world... (3 Replies)
Discussion started by: ric79
3 Replies

3. Shell Programming and Scripting

Split single rows to multiple rows ..

Hi pls help me out to short out this problem rm PAB113_011.out rm: PAB113_011.out: override protection 644 (yes/no)? n If i give y it remove the file. But i added the rm command as a part of ksh file and i tried to remove the file. Its not removing and the the file prompting as... (7 Replies)
Discussion started by: sri_aue
7 Replies

4. Shell Programming and Scripting

split paste them in rows

Hi, I have a file as ABC 123_456_789 234_678_901 XYZ 1100_1250_1580_1680 1175_1440_1620_1890 so on What I want my output file to look is "split by underscore and then place the contents in rows" output ABC 123 234 ABC 456 678 ABC 789 901 XYZ 1100 1175 XYZ 1250 1440... (3 Replies)
Discussion started by: Diya123
3 Replies

5. Shell Programming and Scripting

Deleting all the fields(columns) from a .csv file if all rows in that columns are blanks

Hi Friends, I have come across some files where some of the columns don not have data. Key, Data1,Data2,Data3,Data4,Data5 A,5,6,,10,, A,3,4,,3,, B,1,,4,5,, B,2,,3,4,, If we see the above data on Data5 column do not have any row got filled. So remove only that column(Here Data5) and... (4 Replies)
Discussion started by: ks_reddy
4 Replies

6. Shell Programming and Scripting

Evaluate 2 columns, add sum IF two columns match on two rows

Hi all, I know this sounds suspiciously like a homework course; but, it is not. My goal is to take a file, and match my "ID" column to the "Date" column, if those conditions are true, add the total number of minutes worked and place it in this file, while not printing the original rows that I... (6 Replies)
Discussion started by: mtucker6784
6 Replies

7. Shell Programming and Scripting

Compare 2 csv files by columns, then extract certain columns of matcing rows

Hi all, I'm pretty much a newbie to UNIX. I would appreciate any help with UNIX coding on comparing two large csv files (greater than 10 GB in size), and output a file with matching columns. I want to compare file1 and file2 by 'id' and 'chain' columns, then extract exact matching rows'... (5 Replies)
Discussion started by: bkane3
5 Replies

8. Shell Programming and Scripting

awk split columns after matching on rows and summing the last column

input: chr1 1 2 3 chr1 1 2 4 chr1 2 4 5 chr2 3 6 9 chr2 3 6 10 Code: awk '{a+=$4}END{for (i in a) print i,a}' input Output: chr112 7 chr236 19 chr124 5 Desired output: chr1 1 2 7 chr2 3 6 19 chr1 2 4 5 (1 Reply)
Discussion started by: jacobs.smith
1 Replies

9. Shell Programming and Scripting

How to split all columns into multiple columns?

Hi, all. How can I split all columns into multiple columns separated by tab? Input: qq ee TT 12 m1 aa gg GG 34 2u zz dd hh 56 4h ww cc JJ 78 5y ss ff kk 90 j8 xx pp mm 13 p0 Output: q q e e T T 1 2 m 1 a a g g G G 3 4 2 u z z d d h h 5 6 4 h w w c c J J 7 8 5 y (8 Replies)
Discussion started by: huiyee1
8 Replies

10. Shell Programming and Scripting

Split multi columns line to 2 columns

I have data like this 1 a,b,c 2 a,c 3 b,d 4 e,f would like convert like this 1 a 1 b 1 c 2 a 2 c 3 b 3 d 4 e 4 f Please help me out (4 Replies)
Discussion started by: jhonnyrip
4 Replies
DateTime::Locale::si_LK(3)				User Contributed Perl Documentation				DateTime::Locale::si_LK(3)

NAME
DateTime::Locale::si_LK SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'si_LK' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Sinhala Sri Lanka. DATA
This locale inherits from the DateTime::Locale::si locale. It contains the following data. Days Wide (format) XXXXX XXXXXXXXX XXXXX XXXXXXXXXXXXXX XXXXXXXX XXXXXXXXX XXXXX Abbreviated (format) XXX XX XXX XXXXX XXXX XXX XXX Narrow (format) X X X XXXX XX XX X Wide (stand-alone) XXXXX XXXXXXXXX XXXXX XXXXXXXXXXXXXX XXXXXXXX XXXXXXXXX XXXXX Abbreviated (stand-alone) XXX XX XXX XXXXX XXXX XXX XXX Narrow (stand-alone) X X X XXXX XX XX X Months Wide (format) XXXXX XXXXXXX XXXXX XXXXXXXX XXXX XXX XXXX XXXXXXX XXXXXXXXXXX XXXXXXXX XXXXXXXXX XXXXXXXXX Abbreviated (format) XX XXX XXXXX XXXXXXX XXX XXX XXX XXX XXX XX XXXX XXXX Narrow (format) X XX XX X XX XX XX X XX X XX XX Wide (stand-alone) XXXXX XXXXXXX XXXXX XXXXXXXX XXXX XXX XXXX XXXXXXX XXXXXXXXXXX XXXXXXXX XXXXXXXXX XXXXXXXXX Abbreviated (stand-alone) XX XXX XXXXX XXXXXXX XXX XXX XXX XXX XXX XX XXXX XXXX Narrow (stand-alone) X XX XX X XX XX XX X XX X XX XX Quarters Wide (format) 1 XX XXXXXXX 2 XX XXXXXXX 3 XX XXXXXXX 4 XX XXXXXXX Abbreviated (format) XXXX:1 XXXX:2 XXXX:3 XXXX:4 Narrow (format) 1 2 3 4 Wide (stand-alone) 1 XX XXXXXXX 2 XX XXXXXXX 3 XX XXXXXXX 4 XX XXXXXXX Abbreviated (stand-alone) XXXX:1 XXXX:2 XXXX:3 XXXX:4 Narrow (stand-alone) 1 2 3 4 Eras Wide XXXXXXXXX XXXXXX XXXXXXXXX XXXXX Abbreviated XXXXX.XX. XXXXX.X. Narrow XXXXX.XX. XXXXX.X. Date Formats Full 2008-02-05T18:30:30 = XXXXXXXXX, 2008 XXXXXXX 5 1995-12-22T09:05:02 = XXXXXXXX, 1995 XXXXXXXXX 22 -0010-09-15T04:44:23 = XXXXXXXXX, -10 XXXXXXXXXXX 15 Long 2008-02-05T18:30:30 = 2008 XXXXXXX 5 1995-12-22T09:05:02 = 1995 XXXXXXXXX 22 -0010-09-15T04:44:23 = -10 XXXXXXXXXXX 15 Medium 2008-02-05T18:30:30 = 2008 XXX 5 1995-12-22T09:05:02 = 1995 XXXX 22 -0010-09-15T04:44:23 = -10 XXX 15 Short 2008-02-05T18:30:30 = 2008/02/05 1995-12-22T09:05:02 = 1995/12/22 -0010-09-15T04:44:23 = -010/09/15 Default 2008-02-05T18:30:30 = 2008 XXX 5 1995-12-22T09:05:02 = 1995 XXXX 22 -0010-09-15T04:44:23 = -10 XXX 15 Time Formats Full 2008-02-05T18:30:30 = 6:30:30 X.X. UTC 1995-12-22T09:05:02 = 9:05:02 XX.X. UTC -0010-09-15T04:44:23 = 4:44:23 XX.X. UTC Long 2008-02-05T18:30:30 = 6:30:30 X.X. UTC 1995-12-22T09:05:02 = 9:05:02 XX.X. UTC -0010-09-15T04:44:23 = 4:44:23 XX.X. UTC Medium 2008-02-05T18:30:30 = 6:30:30 X.X. 1995-12-22T09:05:02 = 9:05:02 XX.X. -0010-09-15T04:44:23 = 4:44:23 XX.X. Short 2008-02-05T18:30:30 = 6:30 X.X. 1995-12-22T09:05:02 = 9:05 XX.X. -0010-09-15T04:44:23 = 4:44 XX.X. Default 2008-02-05T18:30:30 = 6:30:30 X.X. 1995-12-22T09:05:02 = 9:05:02 XX.X. -0010-09-15T04:44:23 = 4:44:23 XX.X. Datetime Formats Full 2008-02-05T18:30:30 = XXXXXXXXX, 2008 XXXXXXX 5 6:30:30 X.X. UTC 1995-12-22T09:05:02 = XXXXXXXX, 1995 XXXXXXXXX 22 9:05:02 XX.X. UTC -0010-09-15T04:44:23 = XXXXXXXXX, -10 XXXXXXXXXXX 15 4:44:23 XX.X. UTC Long 2008-02-05T18:30:30 = 2008 XXXXXXX 5 6:30:30 X.X. UTC 1995-12-22T09:05:02 = 1995 XXXXXXXXX 22 9:05:02 XX.X. UTC -0010-09-15T04:44:23 = -10 XXXXXXXXXXX 15 4:44:23 XX.X. UTC Medium 2008-02-05T18:30:30 = 2008 XXX 5 6:30:30 X.X. 1995-12-22T09:05:02 = 1995 XXXX 22 9:05:02 XX.X. -0010-09-15T04:44:23 = -10 XXX 15 4:44:23 XX.X. Short 2008-02-05T18:30:30 = 2008/02/05 6:30 X.X. 1995-12-22T09:05:02 = 1995/12/22 9:05 XX.X. -0010-09-15T04:44:23 = -010/09/15 4:44 XX.X. Default 2008-02-05T18:30:30 = 2008 XXX 5 6:30:30 X.X. 1995-12-22T09:05:02 = 1995 XXXX 22 9:05:02 XX.X. -0010-09-15T04:44:23 = -10 XXX 15 4:44:23 XX.X. Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 XX 1995-12-22T09:05:02 = 22 XXXX -0010-09-15T04:44:23 = 15 XXX Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 X.X. 1995-12-22T09:05:02 = 9:05 XX.X. -0010-09-15T04:44:23 = 4:44 XX.X. Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 X.X. 1995-12-22T09:05:02 = 9:05:02 XX.X. -0010-09-15T04:44:23 = 4:44:23 XX.X. M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (M-d) 2008-02-05T18:30:30 = 2-5 1995-12-22T09:05:02 = 12-22 -0010-09-15T04:44:23 = 9-15 MEd (E, M-d) 2008-02-05T18:30:30 = XX, 2-5 1995-12-22T09:05:02 = XXXX, 12-22 -0010-09-15T04:44:23 = XXX, 9-15 MMM (LLL) 2008-02-05T18:30:30 = XXX 1995-12-22T09:05:02 = XXXX -0010-09-15T04:44:23 = XXX MMMd (MMM d) 2008-02-05T18:30:30 = XXX 5 1995-12-22T09:05:02 = XXXX 22 -0010-09-15T04:44:23 = XXX 15 MMMEd (E MMM d) 2008-02-05T18:30:30 = XX XXX 5 1995-12-22T09:05:02 = XXXX XXXX 22 -0010-09-15T04:44:23 = XXX XXX 15 MMMMd (MMMM d) 2008-02-05T18:30:30 = XXXXXXX 5 1995-12-22T09:05:02 = XXXXXXXXX 22 -0010-09-15T04:44:23 = XXXXXXXXXXX 15 MMMMEd (E MMMM d) 2008-02-05T18:30:30 = XX XXXXXXX 5 1995-12-22T09:05:02 = XXXX XXXXXXXXX 22 -0010-09-15T04:44:23 = XXX XXXXXXXXXXX 15 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (y-M) 2008-02-05T18:30:30 = 2008-2 1995-12-22T09:05:02 = 1995-12 -0010-09-15T04:44:23 = -10-9 yMEd (EEE, y-M-d) 2008-02-05T18:30:30 = XX, 2008-2-5 1995-12-22T09:05:02 = XXXX, 1995-12-22 -0010-09-15T04:44:23 = XXX, -10-9-15 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 XXX 1995-12-22T09:05:02 = 1995 XXXX -0010-09-15T04:44:23 = -10 XXX yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = XX, 2008 XXX 5 1995-12-22T09:05:02 = XXXX, 1995 XXXX 22 -0010-09-15T04:44:23 = XXX, -10 XXX 15 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 XXXXXXX 1995-12-22T09:05:02 = 1995 XXXXXXXXX -0010-09-15T04:44:23 = -10 XXXXXXXXXXX yQ (y Q) 2008-02-05T18:30:30 = 2008 1 1995-12-22T09:05:02 = 1995 4 -0010-09-15T04:44:23 = -10 3 yQQQ (y QQQ) 2008-02-05T18:30:30 = 2008 XXXX:1 1995-12-22T09:05:02 = 1995 XXXX:4 -0010-09-15T04:44:23 = -10 XXXX:3 Miscellaneous Prefers 24 hour time? No Local first day of the week XXXXX SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.16.3 2014-06-10 DateTime::Locale::si_LK(3)
All times are GMT -4. The time now is 05:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy