generate report based on data in files.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting generate report based on data in files.
# 1  
Old 09-20-2011
generate report based on data in files.

Hi All,
I need to develop a shell script which does sanity check of a data file, as below.
1. For DATE columns, it should check if date is given in proper format or not? For example, if format of date is expected as DD-MON-YYYY HH24:MI:SS and we received the date in formation like DDMMYYYY HH24, then it is invalid.
2. For NUMERIC columns, it should check if the numeric value is in given format or not. For example, if expected formart is 9999.99 and we received it as 9999 or expected format is 9999 and we received it in 9999.99 then it is invalid. (it is also possible that sometime we accept 9999 and 9999.99)
3. For character column, it should check, the maximum length.
For all above 3 critetia, we also need to check if NULL values are expected or not. For example, one column which contains date, it should check the format of date as well as if any row has NULL value or not.
At the end, it should generate the report.
I am able to achive the 3rd and 2nd scenarios. But am not able to find solution for DATE columns. In past i have done it using ckdate function, available in UNIX< but in my current UNIX version, ckdate is not installed and i want to make this script as generic, so that it does not depend on any in-built function.
# 2  
Old 09-20-2011
Maybe something with awk:

Code:
echo "11-SEP-2001 08:46:00" | awk '{ if (match($0, "[0-3][0-9]-[[:alpha:]][[:alpha:]][[:alpha:]]-[0-9][0-9][0-9][0-9] ..:..:..$")) print "OK" }'

Or even egrep?

Code:
[mute@geek ~]$ echo "11-SEP-2001 08:46:00" | egrep -q '^..-...-.... ..:..:..$'; echo $?
0

Edit to suit..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Generate files and use csv data to replace multiple variables in a template

I have a source csv file consists of first field as variable name, and the rest are site-specific information (converted from excel file, where site -specific values in columns). I am trying to create a file for every site using a template and replace the multiple variables with values from the... (3 Replies)
Discussion started by: apalex
3 Replies

2. Shell Programming and Scripting

In PErl script: need to read the data one file and generate multiple files based on the data

We have the data looks like below in a log file. I want to generat files based on the string between two hash(#) symbol like below Source: #ext1#test1.tale2 drop #ext1#test11.tale21 drop #ext1#test123.tale21 drop #ext2#test1.tale21 drop #ext2#test12.tale21 drop #ext3#test11.tale21 drop... (5 Replies)
Discussion started by: Sanjeev G
5 Replies

3. Shell Programming and Scripting

Generate Join clause based on key data

Hi, I have a file pk.txt which has pk data in following format TableName | PK Employee | id Contact|name,country My Output should be Employee | t1.id=s.id Contact| t1.name=s.name AND t1.country=s.country I started of like this: for LIST in `cat pk.txt` do... (5 Replies)
Discussion started by: wahi80
5 Replies

4. Shell Programming and Scripting

Generate tabular data based on a column value from an existing data file

Hi, I have a data file with : 01/28/2012,1,1,98995 01/28/2012,1,2,7195 01/29/2012,1,1,98995 01/29/2012,1,2,7195 01/30/2012,1,1,98896 01/30/2012,1,2,7083 01/31/2012,1,1,98896 01/31/2012,1,2,7083 02/01/2012,1,1,98896 02/01/2012,1,2,7083 02/02/2012,1,1,98899 02/02/2012,1,2,7083 I... (1 Reply)
Discussion started by: himanish
1 Replies

5. Shell Programming and Scripting

Generate files from one file based on lines

Hi Friends, I have a file1 file1.txt 1ABC 13478 aqjerh 473 343 2hej 478 5775 24578 23892 3fhd fg 847 brjkb f99345 487 4eh ehjk 84 47589 8947 234 5784 487 738 52895 8975 6 57489 eghe9 4575 859479 7fnbd 4y5 4iuy 458 h irh 8fjdg 74 7845 8475 5789 94yr 48yr 4hr erhj reh... (3 Replies)
Discussion started by: i150371485
3 Replies

6. Shell Programming and Scripting

Generate zone files based off subnet

Hi, I'm attempting to generate zone files based off the subnet address of a reverse zone. For example... My text file contains the following.. 5.4.7.0/24 5.4.7.0/24 68.74.23.0/24 68.74.24.0/24 I want to create a separate file for each of the listed blocks. Each file should contain... (1 Reply)
Discussion started by: spartan22
1 Replies

7. Shell Programming and Scripting

How to generate a csv files by separating the values from the input file based on position?

Hi All, I need help for doing the following. I have a input file like: aaaaaaaaaabbbbbbbbbbbbbbbbbbbb cccbbbbbaaaaaadddddaaaabbbbbbb now I am trying to generate a output csv file where i will have for e.g. 0-3 chars of each line as the first column in the csv, 4-10 chars of the line as... (3 Replies)
Discussion started by: babom
3 Replies

8. Shell Programming and Scripting

Renaming files based on data in a spreadsheet

I have a spreadsheet in a folder that looks like this: Sector1...Sector2...Sector3...Sector4...Sector5...Sector6...Sector7 SomeID....Title.......SomeID...SomeID....SomeID...SomeID....SomeID OtherID...MyTitle....SomeID...SomeID....SomeID...SomeID....SomeID... (7 Replies)
Discussion started by: Xterra
7 Replies

9. UNIX for Dummies Questions & Answers

Report of duplicate files based on part of the filename

I have the files logged in the file system with names in the format of : filename_ordernumber_date_time eg: file_1_12012007_1101.txt file_2_12022007_1101.txt file_1_12032007_1101.txt I need to find out all the files that are logged multiple times with same order number. In the above eg, I... (1 Reply)
Discussion started by: sudheshnaiyer
1 Replies

10. Shell Programming and Scripting

Help generate report from log files

Hi Expert, I have some confusing to generate report from the log file as shown below: filename :test1.log start_time date end_time number code P 000029.621 20070823 000029 12134567890 111111111111 00 0 000 003... (4 Replies)
Discussion started by: bucci
4 Replies
Login or Register to Ask a Question