Sponsored Content
Full Discussion: awk data validation
Top Forums UNIX for Advanced & Expert Users awk data validation Post 84672 by Ygor on Tuesday 27th of September 2005 08:55:17 PM
Old 09-27-2005
Add zero...
Code:
awk 'BEGIN{
  v="123"
  if ((v+0)==v) printf "%s is a number\n", v
  v="abc"
  if ((v+0)!=v) printf "%s is a string\n", v
}'

123 is a number
abc is a string
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Data Validation

Hello, I am trying to use data validation with a program. I have everything else working fine. I just can't figure out what I am doing wrong with the data validation in one of my files. Here is the code: # data validation loop while : do # get input from keyboard ... (2 Replies)
Discussion started by: ericelysia
2 Replies

2. Shell Programming and Scripting

validation of data using filter (awk or other that works...) in csv files

Hello People I have the following file.csv: date,string,float,number,boolean 20080303,abc,1.5,123,Y 20080304,abc,1.2,345,N 20080229,nvh,1.4,098,Y 20080319,ugy,1.9,586,N 20080315,gyh,2.4,345,Y 20080316,erf,3.1,932,N I need to filter the date field where I have a data bigger than I... (1 Reply)
Discussion started by: Rafael.Buria
1 Replies

3. Shell Programming and Scripting

shell script data & time validation

How to validate a date and optionly a time in shell scripting when i get the date and time as pararmeters that sent out with the call of the file? (in my case sh union.sh `first parameter ,second parameter...` (4 Replies)
Discussion started by: tal
4 Replies

4. Shell Programming and Scripting

Data Validation

I have a comma delimited file that I need to validate the data in one two columns in. Sample File: 1234,1234,1234,DESCRIPTION,1,1,2 1234,1234,1234,DESCRIPTION,1,1,2 1234,1234,1234,DESCRIPTION,1,1,2 1234,1234,1234,DESCRIPTION,1,1,2 I need to make sure that the second column's entries are... (3 Replies)
Discussion started by: hmnetonline
3 Replies

5. Shell Programming and Scripting

File and Data Validation.

Hello, I am working on an interface between a legacy system and an ERP system.The format of the data extracted into the staging folder from the legacy system is a follows. One control file named ExtractDataControl.txt Multiple entity files eg R1001.txt, R1002.txt, R1020.txt The control... (5 Replies)
Discussion started by: Savio_Saldanha
5 Replies

6. Shell Programming and Scripting

basic data validation

hpux. older version. don't have alot of the newer features in some utilities. How do I verify that a variable starts with the letter A. I would like to make it case insensitive. Also, if I have a variable that has letters and numbers. I want to change all the lower case letters to upper case.... (2 Replies)
Discussion started by: guessingo
2 Replies

7. Shell Programming and Scripting

Data validation engine

Generic Data validator Data file: Name,Sal,Dept ABC,1234,D1 AYX,12356,D2 DHF,345,ED3 123,4565,FGJG Config File: Delimiter-"," Rule1-Name- Rule2-Sal- Rule3-Dept-* Can be used to match any regex including date different format and numbers. (3 Replies)
Discussion started by: dikesm
3 Replies

8. Shell Programming and Scripting

Help With UNIX Shell Scripting For Data Validation

Hi All, I am completely new to Unix Shell Scripting. I m validating(Basic File Validation) an .HHT file in TIBCO. After that i need to do Data Validation through UNIX Shell scripting. Rules in DataValidation: 1.) Need to Check Every field wheather it is a Char or Number?(Fields are... (1 Reply)
Discussion started by: Chaitanya K
1 Replies

9. Shell Programming and Scripting

Source data validation

I am using below logic to validate whether i am expecting the correct data from source,if not logic should give which column has error.i am running below logic in linux awk -F, ' NR==1{next} {f=" "} $1!~/^{0,5}$|^$/{f=f?f" emp_id-error":"emp_id-error"} $4!~/^{0,6}$|^$/{f=f?f"... (4 Replies)
Discussion started by: katakamvivek
4 Replies
DBIx::DR(3pm)						User Contributed Perl Documentation					     DBIx::DR(3pm)

NAME
DBIx::DR - easy DBI helper (perl inside SQL and blessed results) SYNOPSIS
my $dbh = DBIx::DR->connect($dsn, $login, $passed); $dbh->perform( 'UPDATE tbl SET a = 1 WHERE id = <%= $id %>', id => 123 ); my $rowset = $dbh->select( 'SELECT * FROM tbl WHERE id IN (<% list @$ids %>)', ids => [ 123, 456 ] ); my $rowset = $dbh->select(-f => 'sqlfile.sql.ep', ids => [ 123, 456 ]); while(my $row = $rowset->next) { print "id: %d, value: %s ", $row->id, $row->value; } DESCRIPTION
The package extends DBI and allows You: o to use perl inside Your SQL requests; o to bless resultsets into Your package; o to place Your SQL's into dedicated directory; o to use usual DBI methods. Additional 'connect' options. dr_iterator A string describes iterator class. Default value is 'dbix-dr-iterator#new' (decamelized string). dr_item A string describes item (one row) class. Default value is 'dbix-dr-iterator-item#new' (decamelized string). dr_sql_dir Directory path to seek sql files (If You use dedicated SQLs). dr_decode_errors Decode database errors into utf-8 METHODS
All methods can receive the following arguments: -f => $sql_file_name It will load SQL-request from file. It will seek file in directory that was defined in dr_sql_dir param of connect. You needn't to use suffixes (.sql.ep) here, but You can. -item => 'decamelized_obj_define' It will bless (or construct) row into specified class. See below. Default value defined by dr_item argument of DBI::connect. -noitem Do not bless row into any class. -iterator => 'decamelized_obj_define' It will bless (or construct) rowset into specified class. Default value defined by dr_iterator argument of DBI::connect. -noiterator Do not bless rowset into any class. -dbi => HASHREF Additional DBI arguments. -hash => FIELDNAME Selects into HASH. Iterator will operate by names (not numbers). Decamelized strings Are strings that represent class [ and method ]. foo_bar => FooBar foo_bar#subroutine => FooBar->subroutine foo_bar-baz => FooBar::Baz perform Does SQL-request like 'UPDATE', 'INSERT', etc. $dbh->perform($sql, value => 1, other_value => 'abc'); $dbh->perform(-f => $sql_file_name, value => 1, other_value => 'abc'); select Does SQL-request, pack results into iterator class. By default it uses DBIx::DR::Iterator class. my $res = $dbh->select(-f => $sql_file_name, value => 1); while(my $row = $res->next) { printf "RowId: %d, RowValue: %s ", $row->id, $row->value; } my $row = $row->get(15); # row 15 my $res = $dbh->select(-f => $sql_file_name, value => 1, -hash => 'name'); while(my $row = $res->next) { printf "RowId: %d, RowName: %s ", $row->id, $row->name; } my $row = $row->get('Vasya'); # row with name eq 'Vasya' single Does SQL-request that returns one row. Pack results into item class. Does SQL-request, pack results (one row) into item class. By default it uses DBIx::DR::Iterator::Item class. Template language You can use perl inside Your SQL requests: % my $foo = 1; % my $bar = 2; <% my $foo_bar = $foo + $bar %> .. % use POSIX; % my $gid = POSIX::getgid; There are two functions available inside perl: quote Replaces argument to '?', add argument value into bindlist. You can also use shortcut '=' instead of the function. Example 1 SELECT * FROM tbl WHERE id = <% quote $id %> Result SELECT * FROM tbl WHERE id = ? and bindlist will contain id value. If You use DBIx::DR::ByteStream in place of string the function will recall immediate function. Example 2 SELECT * FROM tbl WHERE id = <%= $id %> immediate Replaces argument to its value. You can also use shortcut '==' instead of the function. Example 1 SELECT * FROM tbl WHERE id = <% immediate $id %> Result SELECT * FROM tbl WHERE id = 123 Where 123 is id value. Be carful! Using the operator You can produce code that will be amenable to SQL-injection. Example 2 SELECT * FROM tbl WHERE id = <%== $id %> Helpers There are a few default helpers. list Expands array into Your SQL request. Example SELECT * FROM tbl WHERE status IN (<% list @$ids %>) Result SELECT * FROM tbl WHERE status IN (?,?,? ...) and bindlist will contain ids values. hlist Expands array of hash into Your SQL request. The first argument can be a list of required keys. Places each group into brackets. Example INSERT INTO tbl ('a', 'b') VALUES <% hlist ['a', 'b'] => @$inserts Result INSERT INTO tbl ('a', 'b') VALUES (?, ?), (?, ?) ... and bindlist will contain all inserts values. include Includes the other SQL-part. Example % include 'other_sql', argument1 => 1, argument2 => 2; User's helpers You can add Your helpers using method set_helper. set_helper Sets (or replaces) helpers. $dbh->set_helper(foo => sub { ... }, bar => sub { ... }); Each helper receives template object as the first argument. Examples: $dbh->set_helper(foo_AxB => sub { my ($tpl, $a, $b) = @_; $tpl->quote($a * $b); }); You can use quote and immediate functions inside Your helpers. If You want use the other helper inside Your helper You have to do that by Yourself. To call the other helper You can also use "$tpl->call_helper" function. call_helper $dbh->set_helper( foo => sub { my ($tpl, $a, $b) = @_; $tpl->quote('foo' . $a . $b); }, bar => sub { my $tpl = shift; $tpl->call_helper(foo => 'b', 'c'); } ); COPYRIGHT
Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org> Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru> This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License. VCS
The project is placed git repo on github: https://github.com/unera/dbix-dr/ <https://github.com/unera/dbix-dr/> perl v5.14.2 2012-05-11 DBIx::DR(3pm)
All times are GMT -4. The time now is 12:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy