Sponsored Content
Top Forums Shell Programming and Scripting How to check Null values in a file column by column if columns are Not NULLs Post 302116221 by Mandab on Wednesday 2nd of May 2007 11:25:15 AM
Old 05-02-2007
I tried with the sample data but it is not giving the exact output:
The sample data is :
545689512<tab>20070424<tab>20070414<tab>456.25<tab>20061121<tab>pqr
<tab>20060726<tab>20060524<tab>800.12<tab><tab>abc
24<tab><tab>05242006<tab>22.15<tab>20050815<tab>xyz
57<tab>20040425<tab>20041214<tab><tab>20040628<tab>stv

Data will be from 3rd row in the file, the following is the script I tried:

#!/bin/ksh

awk -F"|" 'NR>=3 { ## data is from 3rd row onwards
if ( $2 ~ /^ *$/ ) printf("102")
if ( $4 ~ /^ *$/ ) printf("104")
printf("/n")
}' $1 ## filename

The out put I got is:
$ test6.ksh test1.txt
102104/n102104/n102104/n102104/n$
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Check for null values in a column

Hi All, I have a file with 10 columns and get the required data for nine columns properly except 8th. In 8th column i have both NULL and NON NULL values...i.e certain records have values for all the columns including 8th column and certain records have 8th column as NULL.My requisite is,without... (20 Replies)
Discussion started by: ganesh_248
20 Replies

2. Shell Programming and Scripting

Check for null values in columns

Hi , I have below data with fixed with of 52 bytes having three columns value data. 01930 MA GLOUCESTER 02033 02025 COHASSET 01960 MA ... (3 Replies)
Discussion started by: sonu_pal
3 Replies

3. Shell Programming and Scripting

Check to identify duplicate values at first column in csv file

Hello experts, I have a requirement where I have to implement two checks on a csv file: 1. Check to see if the value in first column is duplicate, if any value is duplicate script should exit. 2. Check to verify if the value at second column is between "yes" or "no", if it is anything else... (4 Replies)
Discussion started by: avikaljain
4 Replies

4. Shell Programming and Scripting

Check null values column

hi, I had a small question.I had a file from which i need to extract data. I have written the below script to check if the file exists and if it exists extract requierd columns from the file. IFILE=/home/home01/Report_1.csv OFILE=/home/home01/name.csv.out1 if #Checks if file exists... (1 Reply)
Discussion started by: Vivekit82
1 Replies

5. Shell Programming and Scripting

Script to check for null values in a column

Hi Guys, I am new to shell script.I need your help to write a shell script. I have a csv file which has 13 columns separated by , I have written below script to fetch required 5 columns. awk -F, '(NR==1){h3=$3;h4=$4;h8=$8;h9=$9;h13=$13;next}(NF>1) \ {print... (5 Replies)
Discussion started by: Vivekit82
5 Replies

6. Linux

To get all the columns in a CSV file based on unique values of particular column

cat sample.csv ID,Name,no 1,AAA,1 2,BBB,1 3,AAA,1 4,BBB,1 cut -d',' -f2 sample.csv | sort | uniq this gives only the 2nd column values Name AAA BBB How to I get all the columns of CSV along with this? (1 Reply)
Discussion started by: sanvel
1 Replies

7. UNIX for Dummies Questions & Answers

Check for not null column in a pipe delimited file

Hi, I have a requirement where I have to check whether the mandatory columns in a pipe delimited file is null and print error message. For eg, I have to check if the 3rd,5th,6th,7th and 8th column are null and print the message "<column name> is null". The data file will have aroung 100,000... (6 Replies)
Discussion started by: reshma15193
6 Replies

8. UNIX for Beginners Questions & Answers

Check for null values in a columns. I have dozen of CSV files in a directory.

Hi Folks, I'm trying to write a simple file sanity check script. I have a directory with dozen CSV files containing id,edname,firstname,lastname,suffix,email. I like to write a awk script to check if first field contain a number and is not empty. and fields number 3,4 & 6 are not empty and... (3 Replies)
Discussion started by: dc34684
3 Replies

9. UNIX for Beginners Questions & Answers

Copy columns from one file into another and get sum of column values and row count

I have a file abc.csv, from which I need column 24(PurchaseOrder_TotalCost) to get the sum_of_amounts with date and row count into another file say output.csv abc.csv- UTF-8,,,,,,,,,,,,,,,,,,,,,,,,, ... (6 Replies)
Discussion started by: Tahir_M
6 Replies
MYSQLI_FETCH_ROW(3)							 1						       MYSQLI_FETCH_ROW(3)

mysqli_result::fetch_row - Get a result row as an enumerated array

       Object oriented style

SYNOPSIS
mixed mysqli_result::fetch_row (void ) DESCRIPTION
Procedural style mixed mysqli_fetch_row (mysqli_result $result) Fetches one row of data from the result set and returns it as an enumerated array, where each column is stored in an array offset starting from 0 (zero). Each subsequent call to this function will return the next row within the result set, or NULL if there are no more rows. PARAMETERS
o $ result -Procedural style only: A result set identifier returned by mysqli_query(3), mysqli_store_result(3) or mysqli_use_result(3). RETURN VALUES
mysqli_fetch_row(3) returns an array of strings that corresponds to the fetched row or NULL if there are no more rows in result set. Note This function sets NULL fields to the PHP NULL value. EXAMPLES
Example #1 Object oriented style <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5"; if ($result = $mysqli->query($query)) { /* fetch object array */ while ($row = $result->fetch_row()) { printf ("%s (%s) ", $row[0], $row[1]); } /* free result set */ $result->close(); } /* close connection */ $mysqli->close(); ?> Example #2 Procedural style <?php $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5"; if ($result = mysqli_query($link, $query)) { /* fetch associative array */ while ($row = mysqli_fetch_row($result)) { printf ("%s (%s) ", $row[0], $row[1]); } /* free result set */ mysqli_free_result($result); } /* close connection */ mysqli_close($link); ?> The above examples will output: Pueblo (USA) Arvada (USA) Cape Coral (USA) Green Bay (USA) Santa Clara (USA) SEE ALSO
mysqli_fetch_array(3), mysqli_fetch_assoc(3), mysqli_fetch_object(3), mysqli_query(3), mysqli_data_seek(3). PHP Documentation Group MYSQLI_FETCH_ROW(3)
All times are GMT -4. The time now is 01:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy