Visit Our UNIX and Linux User Community


Insert values into a file 0 as per the date wise


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Insert values into a file 0 as per the date wise
# 1  
Old 02-16-2016
Insert values into a file 0 as per the date wise

Hi
The file contains 12 months of date and less than 12 months of data I want to display if date filed less than 12 months of data I want to insert a value amount 1 to amount4 0 and dates as well.

Code:
12345|Date|cntry|amount1|amount2|amount3|amoun4
12345|31-01-2015|USA|12543.34|124.45|2345.56|3452.25
12345|28-02-2015|USA|1283.34|123445|235.56|3452.25
12345|31-03-2015|USA|125483.34|1234.45|2345.56|3452.25
12345|30-04-2015|USA|125873.34|234.45|2345.56|452.25
12345|31-05-2015|USA|12783.34|134.45|235.56|3452.25
12345|30-06-2015|USA|12543.34|12234.45|2345.56|452.25
12345|31-07-2015|USA|125843.34|134.45|245.56|3452.25
12345|31-08-2015|USA|125843.34|134.45|245.56|3452.25
12345|30-09-2015|USA|125483.34|134.45|2345.56|352.25
12345|31-10-2015|USA|127543.34|124.45|235.56|3452.25
12345|30-11-2015|USA|172543.34|134.45|235.56|342.25
12345|31-12-2015|USA|12573.34|1234.45|235.56|352.25
12346|31-01-2015|SA|12543.34|1234.45|235.56|352.25
12346|28-02-2015|SA|12543.34|1234.45|234.56|352.25
12346|31-03-2015|SA|12543.34|1234.45|345.56|352.25
12346|30-04-2015|SA|12543.34|1234.45|245.56|342.25
12346|31-05-2015|SA|12543.34|1234.45|245.56|342.25
12347|30-09-2015|US|125483.34|134.45|2345.56|352.25
12347|31-10-2015|US|127543.34|124.45|235.56|3452.25
12347|30-11-2015|US|172543.34|134.45|235.56|342.25
12347|31-12-2015|US|12573.34|1234.45|235.56|352.67

output should be display below mentioned table
Code:
 
 
12345|Date|cntry|amount1|amount2|amount3|amoun4
12345|31-01-2015|USA|12543.34|124.45|2345.56|3452.25
12345|28-02-2015|USA|1283.34|123445|235.56|3452.25
12345|31-03-2015|USA|125483.34|1234.45|2345.56|3452.25
12345|30-04-2015|USA|125873.34|234.45|2345.56|452.25
12345|31-05-2015|USA|12783.34|134.45|235.56|3452.25
12345|30-06-2015|USA|12543.34|12234.45|2345.56|452.25
12345|31-07-2015|USA|125843.34|134.45|245.56|3452.25
12345|31-08-2015|USA|125843.34|134.45|245.56|3452.25
12345|30-09-2015|USA|125483.34|134.45|2345.56|352.25
12345|31-10-2015|USA|127543.34|124.45|235.56|3452.25
12345|30-11-2015|USA|172543.34|134.45|235.56|342.25
12345|31-12-2015|USA|12573.34|1234.45|235.56|352.25
12346|31-01-2015|SA|12543.34|1234.45|235.56|352.25
12346|28-02-2015|SA|12543.34|1234.45|234.56|352.25
12346|31-03-2015|SA|12543.34|1234.45|345.56|352.25
12346|30-04-2015|SA|12543.34|1234.45|245.56|342.25
12346|31-05-2015|SA|12543.34|1234.45|245.56|342.25
12346|30-06-2015|SA|0.00|0.00|0.00|0.00
12346|31-08-2015|SA|0.00|0.00|0.00|0.00
12346|30-09-2015|SA|0.00|0.00|0.00|0.00
12346|31-10-2015|SA|0.00|0.00|0.00|0.00
12346|30-11-2015|SA|0.00|0.00|0.00|0.00
12346|31-12-2015|SA|0.00|0.00|0.00|0.00
12347|31-01-2015|US|0.00|0.00|0.00|0.00
12347|28-02-2015|US|0.00|0.00|0.00|0.00
12347|31-03-2015|US|0.00|0.00|0.00|0.00
12347|30-04-2015|US|0.00|0.00|0.00|0.00
12347|31-05-2015|US|0.00|0.00|0.00|0.00
12347|30-06-2015|US|0.00|0.00|0.00|0.00
12347|31-08-2015|US|0.00|0.00|0.00|0.00
12347|30-09-2015|US|125483.34|134.45|2345.56|352.25
12347|31-10-2015|US|127543.34|124.45|235.56|3452.25
12347|30-11-2015|US|172543.34|134.45|235.56|342.25
12347|31-12-2015|US|12573.34|1234.45|235.56|352.25

---------- Post updated at 06:24 AM ---------- Previous update was at 06:21 AM ----------

please help me out some logic so that i can able to write the script





sorry I missed date September data updated the records .If the date filed is not there then insert the corresponding date and the amount should be zero for all the fileds

Last edited by jagu; 02-16-2016 at 04:04 PM..
# 2  
Old 02-16-2016
Any attempts/ideas/thoughts from your side?

Should 31-07-2015 be set to 0.0 as well?
# 3  
Old 02-16-2016
Why never data for July?

Weird that no data, as input or output, for July.

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date wise calculations?

POST_DATE CHECK_NUMBER TYPE LOGIN_NAME 2015.09.09 XXXXXXXXXX mark XXXXXXXXXX 2015.09.09 XXXXXXXXXX fsadf XXXXXXXXXX 2015.10.05 XXXXXXXXXX defaa XXXXXXXXXX 2015.10.05 XXXXXXXXXX dewe XXXXXXXXXX 2015.10.06 XXXXXXXXXX dqwe XXXXXXXXXX 2015.09.14 XXXXXXXXXX dt4e XXXXXXXXXX... (22 Replies)
Discussion started by: nikhil jain
22 Replies

2. Shell Programming and Scripting

Extract count of string in all files and display on date wise

Hi All, hope you all are doing well! I kindly ask you for shell scripting help, here is the description: I have huge number of files shown below on date wise, which contains different strings(numbers you can say) including 505001 and 602001. ... (14 Replies)
Discussion started by: VasuKukkapalli
14 Replies

3. Shell Programming and Scripting

Generate sum of a particular column date wise

Hi All, I have a file with below content 01/22/2014,23:43:00,1742.8, 01/22/2014,23:43:00,1742.8, 01/22/2014,23:44:00,1749.06666666667, 01/25/2014,23:45:00,2046.45, 01/25/2014,23:43:00,1742.8, 01/25/2014,23:44:00,1749.06666666667, 01/25/2014,23:45:00,2046.45, 01/25/2014,23:43:00,1742.8,... (4 Replies)
Discussion started by: villain41
4 Replies

4. Shell Programming and Scripting

How to read files by Server Creation date wise?

Hi All, I would have many files in the server with xyz*.dat -- Static file name Physical files: xyz1.dat - 01PM xyz2.dat - 02PM xyz3.dat - 03PM In present version we are using for f in $file_name do fname=`ls $f | grep -v ^'\|'$ | sed s/' '/'\\ '/g` .... sqlldr... (4 Replies)
Discussion started by: Dharv
4 Replies

5. Shell Programming and Scripting

insert dummy values in a file

Hey guys, i have a file a.txt and i need to insert a dummy data into it as per the below pattern.. bash: cat a.txt 1234,34 3434,45 4545,56 3434,56 Now i need the file in the below pattern 1234,34,a0001,C_01 3434,45,a0002,C_02 4545,56,a0003,C_03 3434,56,a0004,C_04 here the count of... (3 Replies)
Discussion started by: jaituteja
3 Replies

6. Solaris

delete files by date wise

Hi guys, I want to delete files from june 13 to june 30, using rm command can any one tell me the sintax to remove. I ahve hunderd of core files in my /var dir. so i want to clear last month core files. Thanks in Advance.:)) (2 Replies)
Discussion started by: kurva
2 Replies

7. Shell Programming and Scripting

Need to zip the files date wise --urgent Help needed

Hi all, this is my first post, i need to write a script to zip the files with datewise below are the log files. -rw------- 1 root sso 85316156 May 24 22:11 core_test_smservaz_104_104_1243217459_8896 -rw------- 1 root sso 90413304 May 25 22:12 core_test_smservaz_104_104_1243303895_20912... (4 Replies)
Discussion started by: lcschandu
4 Replies

8. Shell Programming and Scripting

hw to insert array values sequentially in a file

Hi All :), I am very new to unix. I am requiring ur help in developing shell script for below problem. I have to replace the second field of file with values of array sequentially where first field is ValidateKeepVar <File> UT-ExtractField 1 | &LogEntry &Keep(DatatoValidate)... (3 Replies)
Discussion started by: rohiiit.sharma
3 Replies

9. Shell Programming and Scripting

To extract data of a perticular interval (date-time wise)

I want a shell script which extract data from a log file which contains date and time-wise data and i need the data for a perticular interval of time...what can i do??? (3 Replies)
Discussion started by: abhishek27
3 Replies

10. UNIX for Advanced & Expert Users

insert pipe in file to separate values

hi all... i need your help, because i donīt know what to do... i have a flat file like this: B065200512312004123111010000061451 000021853 B065200512312004123111020000621907 000417802 B065200512312004123111030000005214 000005861 B065200512312004123111040000120133 000088448 and i need... (5 Replies)
Discussion started by: DebianJ
5 Replies

Featured Tech Videos