Sponsored Content
Top Forums Shell Programming and Scripting File name and format validation Post 302391065 by vsmeruga on Saturday 30th of January 2010 11:59:05 AM
Old 01-30-2010
Help me

HI rdcwayx,

Thanks for your reply.

I haven't got exact file with me now. sorry for that.
But i know the details of the file.

File is a .csv file and it is comma separated with header, detail and footer values.

File name is VJA_AP_BRSIN_00001_2601201012316.csv

For eg: File has 6 fields which has numeric, string and date fields.
Code:
HSiteID,ICOMS Action,SKU,serial,edate
01,ABC,Pending,23,4,19951227120556
02,DM,Pending,26,5,19951227120556
03,RP,delivered,28,,19951227120556
T3

The level of field validation is more with 4 checks. As i have experience in working on small scripts few years back. I request some one to help me on this...

A) After loading the source VJA_AP_BRSIN_00001_2601201012316.csv file to target xxx.csv file, I need to count the reords matching the target count of records.(In Trailer, i have 3, it should match with target xxx.csv file record count.
B) Datatypes and field value size should match
I mean first field site id should be numeric, 2nd field ICOMS should be string, 3rd string, 4th numeric, 5th numeric, 6th date.
C) if any NOT NULL fields coming as NULL - check
If any of the required fields coming as NULL then we should create a log and send the message that file is invalid, correct it.
D) Need to check whether the file came with header , detail records and footer. If not, log it with message, no footer or no header, etc.

Thank you very much.

---------- Post updated at 11:59 AM ---------- Previous update was at 04:39 AM ----------

One more validation to be done was

E) No. of columns in source file should match as expected(for eg:6 as above file)
and i should check for 'n' no. of files at a time placed in a folder: Srcfile folder.

Thanks,
vsmeruga

Last edited by Scott; 01-30-2010 at 06:44 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unix File Validation! Help

Hi All, I got a file with 3 fields delimited by hyphen "-". I have to validate & cleanse the data before i begine the processing Requirements 1. No record should contain more than 2 delimiters 2. No record should even contain less than 2 delimiters 3. Any records that matches rule 1 &... (8 Replies)
Discussion started by: minnuverma
8 Replies

2. UNIX for Dummies Questions & Answers

File Validation

Hi All, I am new to UNIX scripting. I need to validate a file. I need to check whether the file has a header , detail records and footer. If all the file is good I need to create a status file with the status 'Y' else 'N'. I have pasted the an example of the file below: ... (5 Replies)
Discussion started by: kumar66
5 Replies

3. UNIX for Dummies Questions & Answers

file name with timestamp validation

Hi , I am trying to write a shell script which will validate all .csv file names in a directory , my file name format is as below. CDR_SCAN_Report_YYYYMMDDHHMI.csv 1. I need to validate the name should start with CDR_SCAN_Report. 2. And the time stamp part is a valid time stamp,if it is... (1 Reply)
Discussion started by: shruthidwh
1 Replies

4. Shell Programming and Scripting

File Name Validation

Hi All, I am trying to validate the file name against the naming convention mentioned in configuration file. In the configuration file, the file name convention is mentioned as: Myfile_SQ<NN>_<NN>_YYYYMMDD_HHMMSS.xml The actual file received is Myfile_SQ10_30_20110423_073002.xml How do... (1 Reply)
Discussion started by: angshuman
1 Replies

5. Shell Programming and Scripting

File validation

Hello, File contains 1,3 and 5 are required columns. it's working use this command. awk -F\| '$1 && $3 && $5' test1.txt > test2.txt How can use this unix programming.while using runnign this scirpt,it's raising the error. awk: ^ syntax error #!/usr/bin/ksh `awk -F\| '$1 &&... (3 Replies)
Discussion started by: bammidi
3 Replies

6. Shell Programming and Scripting

XML file validation

Hi, i am new to unix script. i have two xml files. one is orderinfo.xml and another one is xsd file(EmailMessage.xml). we need to compare the both file for poper nodes exists are not. for example: <xsd:element name="EmailMessage"> tag in the EmailMessage.xml file(xsd sheet),this tag... (2 Replies)
Discussion started by: bmk
2 Replies

7. Shell Programming and Scripting

File validation

Hi there, As a part of file validation, I needed to check for delimiter count in the file. My aim is to find, how many records have failed to have predefined numbers of delimiters in the file. My code looks like below i=`awk -F '|' 'NF != 2 {print NR, $0} ' ${pinb_fldr}/${pfile}DAT |... (3 Replies)
Discussion started by: anandapani
3 Replies

8. Shell Programming and Scripting

Validation of date from file name

I'm writing a shell script for cleanup of older files from various sub-directories inside a main directory The structure of directories is as below: Logs daily online archive weekly online archive... (1 Reply)
Discussion started by: asyed
1 Replies

9. UNIX for Dummies Questions & Answers

Validation before moving the File

Hi, Before moving the files from source directory to target directory I need to check if the files have these strings 'Error', 'Not Valid' ,' YTF-' or if the file is a zero byte file, if the file contains these strings or if it is a zero byte file i should log a entry in the log file and fail... (5 Replies)
Discussion started by: gaur.deepti
5 Replies

10. UNIX for Beginners Questions & Answers

Flat File Validation

Hi Team there is a requirement to do validate on Flat files using Shell Scripting. Suppose we have two flat files ( F1, F2). Validation 1. Row count between F1 and F2 a) Write it in a file with results of count of each file and differences if any 2. Apply checksum or any... (1 Reply)
Discussion started by: shlearner
1 Replies
ANNO(1)                                                              [nmh-1.5]                                                             ANNO(1)

NAME
anno - annotate messages SYNOPSIS
anno [+folder] [msgs] [-component field] [-inplace | -noinplace] [-date | -nodate] [-draft] [-append] [-list] [-delete] [-number [num|all]] [-preserve | -nopreserve] [-version] [-help] [-text body] DESCRIPTION
Anno manipulates header fields or annotations in messages. Header fields consist of a field name and an optional field body as defined by RFC-2822. The -component option specifies the field name, and the -text option specifies the field body. The messages are either the msgs in the named folder, or the draft if invoked with the -draft option. Usually, annotation is performed by the commands dist, forw, and repl, if they are given the -anno switch. This allows you to keep track of your distribution of, forwarding of, and replies to a message. By using anno, you can perform arbitrary annotations of your own. Each message selected will be annotated with the lines field: date field: body The -nodate switch inhibits the date annotation, leaving only the body annotation. By default, anno prepends the annotations to the message. Annotations are instead appended if the -append option is specified. If a -component field is not specified when anno is invoked, anno will prompt the user for the name of field for the annotation. The field specified must be a valid 2822-style message field name, which means that it may only consist of alphanumerics and dashes, The body specified is arbitrary text. Normally anno does the annotation inplace in order to preserve any links to the message. You may change this by using the -noinplace switch. The -list option produces a listing of the field bodies for header fields with names matching the specified component, one per line. The listing is numbered, starting at 1, if the -number option is also used. A tab character separates the number and the field body. The field body is treated as if it is a file name, and only the final path name component is listed. The complete field body is listed if the -text option is used, the contents of the text are ignored. The -delete option removes header fields from messages. The first header field whose name matches the component is deleted if no other options are specified. If the -text option is used in conjunction with the -delete option, the first header field whose name matches the component and whose body matches the text is deleted. The text is treated as if it was a file name; if it begins with a slash, the entire field body must match the text, otherwise just the last path name component of the field body must match. If the -number option is used in conjuction with the -delete option, header field num whose name matches the component is deleted. The number matches that which is pro- duced by the -list option. The special value all can be used for the number, and causes all components that match the name to be deleted. By default, anno changes the last-accessed and last-modified times on annotate messages to the time at which the annotation occurs. Anno preserves the original times if the -preserve option is used. A matching -nopreserve option exists that allows time preservation to be turned off if enabled in the profile. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder SEE ALSO
dist(1), forw(1), repl(1) DEFAULTS
`+folder' defaults to the current folder `msgs' defaults to cur `-inplace' `-date' CONTEXT
If a folder is given, it will become the current folder. The first message annotated will become the current message. MH.6.8 11 June 2012 ANNO(1)
All times are GMT -4. The time now is 11:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy