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.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. UNIX for Dummies Questions & Answers
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
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
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
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
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
10. UNIX for Beginners Questions & Answers
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
LEARN ABOUT SUNOS
helpdate
ckdate(1) User Commands ckdate(1)
NAME
ckdate, errdate, helpdate, valdate - prompts for and validates a date
SYNOPSIS
ckdate [-Q] [-W width] [-f format] [-d default] [-h help] [-e error] [-p prompt] [ -k pid [-s signal]]
/usr/sadm/bin/errdate [-W width] [-e error] [-f format]
/usr/sadm/bin/helpdate [-W width] [-h help] [-f format]
/usr/sadm/bin/valdate [-f format] input
DESCRIPTION
The ckdate utility prompts a user and validates the response. It defines, among other things, a prompt message whose response should be a
date, text for help and error messages, and a default value (which will be returned if the user responds with a <RETURN>). The user
response must match the defined format for a date.
All messages are limited in length to 70 characters and are formatted automatically. Any white space used in the definition (including new-
line) is stripped. The -W option cancels the automatic formatting. When a tilde is placed at the beginning or end of a message definition,
the default text will be inserted at that point, allowing both custom text and the default text to be displayed.
If the prompt, help or error message is not defined, the default message (as defined under NOTES) will be displayed.
Three visual tool modules are linked to the ckdate command. They are errdate (which formats and displays an error message), helpdate (which
formats and displays a help message), and valdate (which validates a response). These modules should be used in conjunction with FML
objects. In this instance, the FML object defines the prompt. When format is defined in the errdate and helpdate modules, the messages will
describe the expected format.
OPTIONS
The following options are supported:
-d default Defines the default value as default. The default does not have to meet the format criteria.
-e error Defines the error message as error.
-f format Specifies the format against which the input will be verified. Possible formats and their definitions are:
%b = abbreviated month name (jan, feb, mar)
%B = full month name %d = day of month (01 - 31)
%D = date as %m/%d/%y (the default format)
%e = day of month (1 - 31; single digits are preceded by a blank)
%h = abbreviated month name, identical to %b%
%m = month number (01 - 12)
%y = year within century (for instance, 89)
%Y = year as CCYY (for instance, 1989)
-h help Defines the help messages as help.
-k pid Specifies that process ID pid is to be sent a signal if the user chooses to abort.
-p prompt Defines the prompt message as prompt.
-Q Specifies that quit will not be allowed as a valid response.
-s signal Specifies that the process ID pid defined with the -k option is to be sent signal signal when quit is chosen. If no sig-
nal is specified, SIGTERM is used.
-W width Specifies that prompt, help and error messages will be formatted to a line length of width.
OPERANDS
The following operand is supported:
input Input to be verified against format criteria.
EXIT STATUS
The following exit values are returned:
0 Successful execution.
1 EOF on input, or negative width on -W option, or usage error.
3 User termination (quit).
4 Garbled format argument.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
attributes(5)
NOTES
The default prompt for ckdate is:
Enter the date [?,q]:
The default error message is:
ERROR - Please enter a date. Format is <format>.
The default help message is:
Please enter a date. Format is <format>.
When the quit option is chosen (and allowed), q is returned along with the return code 3. The valdate module will not produce any output.
It returns zero for success and non-zero for failure.
SunOS 5.10 14 Sep 1992 ckdate(1)