Sponsored Content
Top Forums Shell Programming and Scripting Script to validate header in a csv file Post 303018867 by rovf on Monday 18th of June 2018 02:53:00 AM
Old 06-18-2018
The question is incomplete:

Do you require that the header is EXACTLY like the one you posted? In this case, there is nothing CSV-specific in your question. Instead, the problem boils down to finding out, whether the first line of a file has a certain content.

Or do you require that the header is STRUCTURALLY like the one you posted? For example, the CSV-file format allows fields to be quoted; or, you might consider trailing spaces after the header names insignificant; or you might allow the fields to occur in any order. In this case, you need to specify, what exactly are the conditions to regard the header valid.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

validate csv file load

Hi All, I am using sqlldr to load my csv files into the database. The code in the sh script is as follows. sqlldr ${DBUSER}/${DBPASS}@${ORACLE_SID} \ data=myCSV.data \ bad=myCSV.bad \ control=myCSV.ctl \ ... (0 Replies)
Discussion started by: rahulrathod
0 Replies

2. Shell Programming and Scripting

How to validate a CSV file?

Hi. I think some people have already asked this, but the answers/questions seem to be about validating the contents inside a CSV file. I am simply after a simple variable solution (ie 0 = false, 1 = true) that I can use in my script to say that file so-and-so is actually a CSV file, or in some... (4 Replies)
Discussion started by: ElCaito
4 Replies

3. Shell Programming and Scripting

How can I add a header to a csv file

I have a csv file which has no header. the file has 15 fields and needs to go out with a header of 8 fields. The header content needs to have some variables and some fixed that i have set up: variable header fields OUTFILE_YEAR=`date '+%y'` DATE=`date '+%d%m%y'` TIME=`date '+%H:%M:%S'`... (6 Replies)
Discussion started by: Pablo_beezo
6 Replies

4. Shell Programming and Scripting

How to: Validate a CSV file using an XSD?

Hi All, I was wondering if there is a utility/perl library/way of validating the contents of a CSV file using an XSD. i.e. Customer csv (including Header & Trailer) Cust_num, Cust_nme, Cust_typ, Cust_act_dte, Cust_loc, 101,Joe's Pizza,Retail,10121979,Detroit, 102,Sony... (6 Replies)
Discussion started by: luinzi
6 Replies

5. UNIX for Dummies Questions & Answers

Merge all csv files in one folder considering only 1 header row and ignoring header of all others

Friends, I need help with the following in UNIX. Merge all csv files in one folder considering only 1 header row and ignoring header of all other files. FYI - All files are in same format and contains same headers. Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies

6. Shell Programming and Scripting

Script to validate file header and trailer

Hi, I need a script that validates a file header/detail/trailer. File layout is: Header - Rec_Type|File_name|File_Date Detail - Rec_Type|field1|field2|field3... Trailder - Rec_Type|File_name|File_Date|Record_count Sample Data: HDR|customer_data.dat|20120709... (7 Replies)
Discussion started by: ash_sh
7 Replies

7. Shell Programming and Scripting

Exclude the header row in the file to validate

Hi All, File contains header row.. we need to exclude the header row...no need to validate the first row in the file. Data in the file should take valid data(two columns)..we need to exclude the more than two columns in the file except the first line. email|firstname a|123|100 b|345... (4 Replies)
Discussion started by: bmk
4 Replies

8. Shell Programming and Scripting

Script to ingest a csv, validate data and insert into Oracle

Hi all i would appreciate your help... I am looking for a set of unix commands which i can use to 1) ingest a csv file with a known format 2) validate the filename 3) validate the data/datatypes 4) Insert into an oracle db Can you help get me started? yogz888 (1 Reply)
Discussion started by: yogz888
1 Replies

9. UNIX for Beginners Questions & Answers

Validate csv file

Hi guys, i want to validate the no.of colums in a csv file ,but if there is a comma(,) in any of the data values it should skip and count only valid (,) commas. e.g 1.abc,pqrs,1234,567,hhh result :4 2.abc,pqrs,1234,567,hhh,"in,valid",end12 result:6 here script should skip the comma inside... (10 Replies)
Discussion started by: harry123
10 Replies

10. Shell Programming and Scripting

Bash to verify and validate file header and data type

The below bash is a file validation check executed that will verify the correct header count of 10 and the correct data type in each field of the tab-delimited file. The key has the data type of each field in it. My real data has 58 headers in it but only the header and next row need to be... (6 Replies)
Discussion started by: cmccabe
6 Replies
AR(5)							      BSD File Formats Manual							     AR(5)

NAME
ar -- a.out archive (library) file format SYNOPSIS
#include <ar.h> DESCRIPTION
The archive command ar combines several files into one. Archives are mainly used as libraries of object files intended to be loaded using the link-editor ld(1). A file created with ar begins with the ``magic'' string ``!<arch> ''. The rest of the archive is made up of objects, each of which is com- posed of a header for a file, a possible file name, and the file contents. The header is portable between machine architectures, and, if the file contents are printable, the archive is itself printable. The header is made up of six variable length ASCII fields, followed by a two character trailer. The fields are the object name (16 charac- ters), the file last modification time (12 characters), the user and group id's (each 6 characters), the file mode (8 characters) and the file size (10 characters). All numeric fields are in decimal, except for the file mode which is in octal. The modification time is the file st_mtime field, i.e., CUT seconds since the epoch. The user and group id's are the file st_uid and st_gid fields. The file mode is the file st_mode field. The file size is the file st_size field. The two-byte trailer is the string "` ". Only the name field has any provision for overflow. If any file name is more than 16 characters in length or contains an embedded space, the string "#1/" followed by the ASCII length of the name is written in the name field. The file size (stored in the archive header) is incre- mented by the length of the name. The name is then written immediately following the archive header. Any unused characters in any of these fields are written as space characters. If any fields are their particular maximum number of charac- ters in length, there will be no separation between the fields. Objects in the archive are always an even number of bytes long; files which are an odd number of bytes long are padded with a newline (`` '') character, although the size in the header does not reflect this. SEE ALSO
ar(1), stat(2) HISTORY
There have been at least four ar formats. The first was denoted by the leading ``magic'' number 0177555 (stored as type int). These ar- chives were almost certainly created on a 16-bit machine, and contain headers made up of five fields. The fields are the object name (8 characters), the file last modification time (type long), the user id (type char), the file mode (type char) and the file size (type unsigned int). Files were padded to an even number of bytes. The second was denoted by the leading ``magic'' number 0177545 (stored as type int). These archives may have been created on either 16 or 32-bit machines, and contain headers made up of six fields. The fields are the object name (14 characters), the file last modification time (type long), the user and group id's (each type char), the file mode (type int), and the file size (type long). Files were padded to an even number of bytes. Both of these historical formats may be read with ar(1). The current archive format (without support for long character names and names with embedded spaces) was introduced in 4.0BSD. The headers were the same as the current format, with the exception that names longer than 16 characters were truncated, and names with embedded spaces (and often trailing spaces) were not supported. It has been extended for these reasons, as described above. This format first appeared in 4.4BSD. COMPATIBILITY
The current a.out archive format is not specified by any standard. ELF systems use the ar format specified by the AT&T System V Release 4 UNIX ABI, with the same headers but different long file name handling. BUGS
The <ar.h> header file, and the ar manual page, do not currently describe the ELF archive format. BSD
June 1, 1994 BSD
All times are GMT -4. The time now is 02:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy