Sponsored Content
Full Discussion: Split columns into rows
Top Forums Shell Programming and Scripting Split columns into rows Post 302969826 by syd on Tuesday 29th of March 2016 01:23:33 AM
Old 03-29-2016
PFB requirements I have

INPUT FILE
Code:
10000|1442448000000:[-99]|latChangeDate:14457679000|latest:-99
10001|1442448000000:[-99]|latChangeDate:14438549000|latest:351592032174|1448496000000:[35159203213374]
10002|1442448000000:[35578404848006],latChangeDate:1442468000|latest:35578404846
10003
10004|1442448000000:[35872402070386]|latChangeDate:14425248000|latest:358722070386
10005|1448755200000:[35193106096435]|latest:351931096435

code I have used to get value is
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

output I got --where -99 value is missing
Code:
ID|latChangeDate|latest
10000|14457679000|
10001|14438549000|35159203214
10002|1442468000|35578404846
10003|XXXXXXXXX|XXXXXXXXX
10004|14425248000|358722070386
10005|XXXXXXXXX|351931096435

but I should get
Code:
10000|14457679000|-99
10001|14438549000|35159203214
10002|1442468000|35578404846
10003|XXXXXXXXX|XXXXXXXXX
10004|14425248000|358722070386
10005|XXXXXXXXX|351931096435

where -99 value is missing

---------- Post updated 03-29-16 at 12:23 AM ---------- Previous update was 03-28-16 at 11:56 PM ----------

Hi Ravinder,
this is an another file with negative value.

Last edited by syd; 03-29-2016 at 02:13 AM..
 

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

NAME
DateTime::Locale::bn_IN SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'bn_IN' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Bengali India. DATA
This locale inherits from the DateTime::Locale::bn locale. It contains the following data. Days Wide (format) XXXXXX XXXXXXXX XXXXXX XXXXXXXXXXX XXXXXXXX XXXXXX XXXXXX Abbreviated (format) XXX XXXXX XXX XXXXXXXX XXXXX XXX XXX Narrow (format) XX X XX XX XX X X Wide (stand-alone) XXXXXX XXXXXXXX XXXXXX XXXXXXXXXXX XXXXXXXX XXXXXX XXXXXX Abbreviated (stand-alone) XXX XXXXX XXX XXXXXXXX XXXXX XXX XXX Narrow (stand-alone) XX X XX XX XX X X Months Wide (format) XXXXXXXXX XXXXXXXXXXX XXXXX XXXXXX XX XXX XXXXX XXXXX XXXXXXXXXX XXXXXXX XXXXXXX XXXXXXXX Abbreviated (format) XXXXXXXXX XXXXXXXXXXX XXXXX XXXXXX XX XXX XXXXX XXXXX XXXXXXXXXX XXXXXXX XXXXXXX XXXXXXXX Narrow (format) XX XX XX X XX XXX XX X XX X X XX Wide (stand-alone) XXXXXXXXX XXXXXXXXXXX XXXXX XXXXXX XX XXX XXXXX XXXXX XXXXXXXXXX XXXXXXX XXXXXXX XXXXXXXX Abbreviated (stand-alone) XXXXXXXXX XXXXXXXXXXX XXXXX XXXXXX XX XXX XXXXX XXXXX XXXXXXXXXX XXXXXXX XXXXXXX XXXXXXXX Narrow (stand-alone) XX XX XX X XX XXX XX X XX X X XX Quarters Wide (format) XXXXX XXXXXXXXX XXXXXXXX XXXXXXXXX XXXXXX XXXXXXXXX XXXXXX XXXXXXXXX Abbreviated (format) XXXXXXXXX X XXXXXXXXX X XXXXXXXXX X XXXXXXXXX X Narrow (format) X X X X Wide (stand-alone) XXXXX XXXXXXXXX XXXXXXXX XXXXXXXXX XXXXXX XXXXXXXXX XXXXXX XXXXXXXXX Abbreviated (stand-alone) XXXXXXXXX X XXXXXXXXX X XXXXXXXXX X XXXXXXXXX X Narrow (stand-alone) X X X X Eras Wide BCE CE Abbreviated XXXXXXXXXX XXXXXXXXX Narrow XXXXXXXXXX XXXXXXXXX Date Formats Full 2008-02-05T18:30:30 = XXXXXXXX, 5 XXXXXXXXXXX, 2008 1995-12-22T09:05:02 = XXXXXXXX, 22 XXXXXXXX, 1995 -0010-09-15T04:44:23 = XXXXXX, 15 XXXXXXXXXX, -10 Long 2008-02-05T18:30:30 = 5 XXXXXXXXXXX, 2008 1995-12-22T09:05:02 = 22 XXXXXXXX, 1995 -0010-09-15T04:44:23 = 15 XXXXXXXXXX, -10 Medium 2008-02-05T18:30:30 = 5 XXXXXXXXXXX, 2008 1995-12-22T09:05:02 = 22 XXXXXXXX, 1995 -0010-09-15T04:44:23 = 15 XXXXXXXXXX, -10 Short 2008-02-05T18:30:30 = 5/2/08 1995-12-22T09:05:02 = 22/12/95 -0010-09-15T04:44:23 = 15/9/-10 Default 2008-02-05T18:30:30 = 5 XXXXXXXXXXX, 2008 1995-12-22T09:05:02 = 22 XXXXXXXX, 1995 -0010-09-15T04:44:23 = 15 XXXXXXXXXX, -10 Time Formats Full 2008-02-05T18:30:30 = 6:30:30 XXXXXXX UTC 1995-12-22T09:05:02 = 9:05:02 XXXXXXXXX UTC -0010-09-15T04:44:23 = 4:44:23 XXXXXXXXX UTC Long 2008-02-05T18:30:30 = 6:30:30 XXXXXXX UTC 1995-12-22T09:05:02 = 9:05:02 XXXXXXXXX UTC -0010-09-15T04:44:23 = 4:44:23 XXXXXXXXX UTC Medium 2008-02-05T18:30:30 = 6:30:30 XXXXXXX 1995-12-22T09:05:02 = 9:05:02 XXXXXXXXX -0010-09-15T04:44:23 = 4:44:23 XXXXXXXXX Short 2008-02-05T18:30:30 = 6:30 XXXXXXX 1995-12-22T09:05:02 = 9:05 XXXXXXXXX -0010-09-15T04:44:23 = 4:44 XXXXXXXXX Default 2008-02-05T18:30:30 = 6:30:30 XXXXXXX 1995-12-22T09:05:02 = 9:05:02 XXXXXXXXX -0010-09-15T04:44:23 = 4:44:23 XXXXXXXXX Datetime Formats Full 2008-02-05T18:30:30 = XXXXXXXX, 5 XXXXXXXXXXX, 2008 6:30:30 XXXXXXX UTC 1995-12-22T09:05:02 = XXXXXXXX, 22 XXXXXXXX, 1995 9:05:02 XXXXXXXXX UTC -0010-09-15T04:44:23 = XXXXXX, 15 XXXXXXXXXX, -10 4:44:23 XXXXXXXXX UTC Long 2008-02-05T18:30:30 = 5 XXXXXXXXXXX, 2008 6:30:30 XXXXXXX UTC 1995-12-22T09:05:02 = 22 XXXXXXXX, 1995 9:05:02 XXXXXXXXX UTC -0010-09-15T04:44:23 = 15 XXXXXXXXXX, -10 4:44:23 XXXXXXXXX UTC Medium 2008-02-05T18:30:30 = 5 XXXXXXXXXXX, 2008 6:30:30 XXXXXXX 1995-12-22T09:05:02 = 22 XXXXXXXX, 1995 9:05:02 XXXXXXXXX -0010-09-15T04:44:23 = 15 XXXXXXXXXX, -10 4:44:23 XXXXXXXXX Short 2008-02-05T18:30:30 = 5/2/08 6:30 XXXXXXX 1995-12-22T09:05:02 = 22/12/95 9:05 XXXXXXXXX -0010-09-15T04:44:23 = 15/9/-10 4:44 XXXXXXXXX Default 2008-02-05T18:30:30 = 5 XXXXXXXXXXX, 2008 6:30:30 XXXXXXX 1995-12-22T09:05:02 = 22 XXXXXXXX, 1995 9:05:02 XXXXXXXXX -0010-09-15T04:44:23 = 15 XXXXXXXXXX, -10 4:44:23 XXXXXXXXX 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 XXXXX 1995-12-22T09:05:02 = 22 XXXXX -0010-09-15T04:44:23 = 15 XXX Hm (HH:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 XXXXXXX 1995-12-22T09:05:02 = 9:05 XXXXXXXXX -0010-09-15T04:44:23 = 4:44 XXXXXXXXX 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 XXXXXXX 1995-12-22T09:05:02 = 9:05:02 XXXXXXXXX -0010-09-15T04:44:23 = 4:44:23 XXXXXXXXX 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, d-M) 2008-02-05T18:30:30 = XXXXX, 5-2 1995-12-22T09:05:02 = XXXXX, 22-12 -0010-09-15T04:44:23 = XXX, 15-9 MMdd (dd-MM) 2008-02-05T18:30:30 = 05-02 1995-12-22T09:05:02 = 22-12 -0010-09-15T04:44:23 = 15-09 MMM (LLL) 2008-02-05T18:30:30 = XXXXXXXXXXX 1995-12-22T09:05:02 = XXXXXXXX -0010-09-15T04:44:23 = XXXXXXXXXX MMMd (d MMM) 2008-02-05T18:30:30 = 5 XXXXXXXXXXX 1995-12-22T09:05:02 = 22 XXXXXXXX -0010-09-15T04:44:23 = 15 XXXXXXXXXX MMMEd (E d MMM) 2008-02-05T18:30:30 = XXXXX 5 XXXXXXXXXXX 1995-12-22T09:05:02 = XXXXX 22 XXXXXXXX -0010-09-15T04:44:23 = XXX 15 XXXXXXXXXX MMMMd (d MMMM) 2008-02-05T18:30:30 = 5 XXXXXXXXXXX 1995-12-22T09:05:02 = 22 XXXXXXXX -0010-09-15T04:44:23 = 15 XXXXXXXXXX MMMMEd (E d MMMM) 2008-02-05T18:30:30 = XXXXX 5 XXXXXXXXXXX 1995-12-22T09:05:02 = XXXXX 22 XXXXXXXX -0010-09-15T04:44:23 = XXX 15 XXXXXXXXXX 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 (M/yyyy) 2008-02-05T18:30:30 = 2/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 9/-010 yMEd (EEE, d/M/yyy) 2008-02-05T18:30:30 = XXXXX, 5/2/2008 1995-12-22T09:05:02 = XXXXX, 22/12/1995 -0010-09-15T04:44:23 = XXX, 15/9/-10 yMMM (MMM y) 2008-02-05T18:30:30 = XXXXXXXXXXX 2008 1995-12-22T09:05:02 = XXXXXXXX 1995 -0010-09-15T04:44:23 = XXXXXXXXXX -10 yMMMEd (EEE, d MMM, y) 2008-02-05T18:30:30 = XXXXX, 5 XXXXXXXXXXX, 2008 1995-12-22T09:05:02 = XXXXX, 22 XXXXXXXX, 1995 -0010-09-15T04:44:23 = XXX, 15 XXXXXXXXXX, -10 yMMMM (MMMM y) 2008-02-05T18:30:30 = XXXXXXXXXXX 2008 1995-12-22T09:05:02 = XXXXXXXX 1995 -0010-09-15T04:44:23 = XXXXXXXXXX -10 yQ (Q y) 2008-02-05T18:30:30 = 1 2008 1995-12-22T09:05:02 = 4 1995 -0010-09-15T04:44:23 = 3 -10 yQQQ (QQQ y) 2008-02-05T18:30:30 = XXXXXXXXX X 2008 1995-12-22T09:05:02 = XXXXXXXXX X 1995 -0010-09-15T04:44:23 = XXXXXXXXX X -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 yyyyMM (MM-yyyy) 2008-02-05T18:30:30 = 02-2008 1995-12-22T09:05:02 = 12-1995 -0010-09-15T04:44:23 = 09--010 yyyyMMMM (MMMM y) 2008-02-05T18:30:30 = XXXXXXXXXXX 2008 1995-12-22T09:05:02 = XXXXXXXX 1995 -0010-09-15T04:44:23 = XXXXXXXXXX -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::bn_IN(3)
All times are GMT -4. The time now is 03:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy