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::pa(3) 				User Contributed Perl Documentation				   DateTime::Locale::pa(3)

NAME
DateTime::Locale::pa SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'pa' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Punjabi. DATA
This locale inherits from the DateTime::Locale::root locale. It contains the following data. Days Wide (format) XXXXXX XXXXXXX XXXXXX XXXXXX XXXXXXXXX XXXXXXXXX XXXXX Abbreviated (format) XXX. XXXX. XXX. XXX. XXXXX. XXXX. XX. Narrow (format) XX XX XXX XX XXXX XX X Wide (stand-alone) XXXXXX XXXXXXX XXXXXX XXXXXX XXXXXXXXX XXXXXXXXX XXXXX Abbreviated (stand-alone) XXX. XXXX. XXX. XXX. XXXXX. XXXX. XX. Narrow (stand-alone) XX XX XXX XX XXXX XX X Months Wide (format) XXXXX XXXXXX XXXX XXXXXX XX XXX XXXXX XXXX XXXXX XXXXXX XXXXX XXXXX Abbreviated (format) XXXXX XXXXXX XXXX XXXXXX XX XXX XXXXX XXXX XXXXX XXXXXX XXXXX XXXXX Narrow (format) X X XX X X XX XX X X X X X Wide (stand-alone) XXXXX XXXXXX XXXX XXXXXX XX XXX XXXXX XXXX XXXXX XXXXXX XXXXX XXXXX Abbreviated (stand-alone) 1 2 3 4 5 6 7 8 9 10 11 12 Narrow (stand-alone) X X XX X X XX XX X X X X X Quarters Wide (format) XXXXXX XXXXX XXXX XXXXX XXXX XXXXX XXXX XXXXX Abbreviated (format) Q1 Q2 Q3 Q4 Narrow (format) 1 2 3 4 Wide (stand-alone) XXXXXX XXXXX XXXX XXXXX XXXX XXXXX XXXX XXXXX Abbreviated (stand-alone) Q1 Q2 Q3 Q4 Narrow (stand-alone) 1 2 3 4 Eras Wide XXXXXXX XXX Abbreviated BCE CE Narrow BCE CE Date Formats Full 2008-02-05T18:30:30 = XXXXXXX, 05 XXXXXX 2008 1995-12-22T09:05:02 = XXXXXXXXX, 22 XXXXX 1995 -0010-09-15T04:44:23 = XXXXXXXXX, 15 XXXXX -10 Long 2008-02-05T18:30:30 = 5 XXXXXX 2008 1995-12-22T09:05:02 = 22 XXXXX 1995 -0010-09-15T04:44:23 = 15 XXXXX -10 Medium 2008-02-05T18:30:30 = 5 XXXXXX 2008 1995-12-22T09:05:02 = 22 XXXXX 1995 -0010-09-15T04:44:23 = 15 XXXXX -10 Short 2008-02-05T18:30:30 = 05/02/2008 1995-12-22T09:05:02 = 22/12/1995 -0010-09-15T04:44:23 = 15/09/-010 Default 2008-02-05T18:30:30 = 5 XXXXXX 2008 1995-12-22T09:05:02 = 22 XXXXX 1995 -0010-09-15T04:44:23 = 15 XXXXX -10 Time Formats Full 2008-02-05T18:30:30 = 6:30:30 XXXX UTC 1995-12-22T09:05:02 = 9:05:02 XXXXX UTC -0010-09-15T04:44:23 = 4:44:23 XXXXX UTC Long 2008-02-05T18:30:30 = 6:30:30 XXXX UTC 1995-12-22T09:05:02 = 9:05:02 XXXXX UTC -0010-09-15T04:44:23 = 4:44:23 XXXXX UTC Medium 2008-02-05T18:30:30 = 6:30:30 XXXX 1995-12-22T09:05:02 = 9:05:02 XXXXX -0010-09-15T04:44:23 = 4:44:23 XXXXX Short 2008-02-05T18:30:30 = 6:30 XXXX 1995-12-22T09:05:02 = 9:05 XXXXX -0010-09-15T04:44:23 = 4:44 XXXXX Default 2008-02-05T18:30:30 = 6:30:30 XXXX 1995-12-22T09:05:02 = 9:05:02 XXXXX -0010-09-15T04:44:23 = 4:44:23 XXXXX Datetime Formats Full 2008-02-05T18:30:30 = XXXXXXX, 05 XXXXXX 2008 6:30:30 XXXX UTC 1995-12-22T09:05:02 = XXXXXXXXX, 22 XXXXX 1995 9:05:02 XXXXX UTC -0010-09-15T04:44:23 = XXXXXXXXX, 15 XXXXX -10 4:44:23 XXXXX UTC Long 2008-02-05T18:30:30 = 5 XXXXXX 2008 6:30:30 XXXX UTC 1995-12-22T09:05:02 = 22 XXXXX 1995 9:05:02 XXXXX UTC -0010-09-15T04:44:23 = 15 XXXXX -10 4:44:23 XXXXX UTC Medium 2008-02-05T18:30:30 = 5 XXXXXX 2008 6:30:30 XXXX 1995-12-22T09:05:02 = 22 XXXXX 1995 9:05:02 XXXXX -0010-09-15T04:44:23 = 15 XXXXX -10 4:44:23 XXXXX Short 2008-02-05T18:30:30 = 05/02/2008 6:30 XXXX 1995-12-22T09:05:02 = 22/12/1995 9:05 XXXXX -0010-09-15T04:44:23 = 15/09/-010 4:44 XXXXX Default 2008-02-05T18:30:30 = 5 XXXXXX 2008 6:30:30 XXXX 1995-12-22T09:05:02 = 22 XXXXX 1995 9:05:02 XXXXX -0010-09-15T04:44:23 = 15 XXXXX -10 4:44:23 XXXXX 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 XXXX. 1995-12-22T09:05:02 = 22 XXXXX. -0010-09-15T04:44:23 = 15 XXXX. HHmmss (HH:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 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 XXXX 1995-12-22T09:05:02 = 9:05 XXXXX -0010-09-15T04:44:23 = 4:44 XXXXX 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 XXXX 1995-12-22T09:05:02 = 9:05:02 XXXXX -0010-09-15T04:44:23 = 4:44:23 XXXXX M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (d/M) 2008-02-05T18:30:30 = 5/2 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/9 MEd (E, M-d) 2008-02-05T18:30:30 = XXXX., 2-5 1995-12-22T09:05:02 = XXXXX., 12-22 -0010-09-15T04:44:23 = XXXX., 9-15 MMM (LLL) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 MMMd (MMM d) 2008-02-05T18:30:30 = XXXXXX 5 1995-12-22T09:05:02 = XXXXX 22 -0010-09-15T04:44:23 = XXXXX 15 MMMEd (E MMM d) 2008-02-05T18:30:30 = XXXX. XXXXXX 5 1995-12-22T09:05:02 = XXXXX. XXXXX 22 -0010-09-15T04:44:23 = XXXX. XXXXX 15 MMMMd (MMMM d) 2008-02-05T18:30:30 = XXXXXX 5 1995-12-22T09:05:02 = XXXXX 22 -0010-09-15T04:44:23 = XXXXX 15 MMMMEd (E MMMM d) 2008-02-05T18:30:30 = XXXX. XXXXXX 5 1995-12-22T09:05:02 = XXXXX. XXXXX 22 -0010-09-15T04:44:23 = XXXX. XXXXX 15 mmss (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 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 = XXXX., 2008-2-5 1995-12-22T09:05:02 = XXXXX., 1995-12-22 -0010-09-15T04:44:23 = XXXX., -10-9-15 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 XXXXXX 1995-12-22T09:05:02 = 1995 XXXXX -0010-09-15T04:44:23 = -10 XXXXX yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = XXXX., 2008 XXXXXX 5 1995-12-22T09:05:02 = XXXXX., 1995 XXXXX 22 -0010-09-15T04:44:23 = XXXX., -10 XXXXX 15 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 XXXXXX 1995-12-22T09:05:02 = 1995 XXXXX -0010-09-15T04:44:23 = -10 XXXXX 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 Q1 1995-12-22T09:05:02 = 1995 Q4 -0010-09-15T04:44:23 = -10 Q3 yyMMM (MMM yy) 2008-02-05T18:30:30 = XXXXXX 08 1995-12-22T09:05:02 = XXXXX 95 -0010-09-15T04:44:23 = XXXXX -10 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 Miscellaneous Prefers 24 hour time? No Local first day of the week XXXXXX 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.18.2 2017-10-06 DateTime::Locale::pa(3)
All times are GMT -4. The time now is 04:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy