Sponsored Content
Full Discussion: Reading CSV file
Top Forums Shell Programming and Scripting Reading CSV file Post 303010308 by RudiC on Friday 29th of December 2017 12:28:25 PM
Old 12-29-2017
Not fully understanding what you're after, how about
Code:
awk '
                {++CNT[$3]
                }

$2 == "non"     {NON[$3] = NR
                }

NON[$3] &&
(CNT[$3] > 1)   {print "error ", NON[$3]
                }
' file
error  7

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script for reading .csv file

Can someone please help me to write script for following scenario : 1> script should read a input .csv file of format : EmpName, PF, Leave, Basic ,HRA 2> another config file ( may be again a .csv file ) has format EmpName and EmpID 3> script should read another config file for each EmpName in... (3 Replies)
Discussion started by: creativeworld
3 Replies

2. Shell Programming and Scripting

reading from a .csv file

Hi , Can anyone please help me to read the value from the .csv file? This is my .csv file: dirnames: first,second i want to get the two names and create directories correspondingly (1 Reply)
Discussion started by: novice_user
1 Replies

3. UNIX for Advanced & Expert Users

Issue reading csv file

HI All I have csv file containing the data like this Electrical Equipment,ElecEquip "Engineering, Machinery & Equipment",Engineerin Entertainment & Broadcasting,Entertain The first and third record are fine,The issue with second records as it has comma enclosed with in inverted... (1 Reply)
Discussion started by: mohdtausifsh
1 Replies

4. Shell Programming and Scripting

Reading variables from CSV file

Hi I am using KSH and trying to read variables from a csv file. I've set the IFS=, and it workds. Problem is where one of the values is text containing a comma. For example the following lines exist in my file. How can I read everything between the quotes into a single variable? APW13812,,1... (2 Replies)
Discussion started by: ventris
2 Replies

5. Shell Programming and Scripting

reading a csv file and creating a flat file

hi i have written a script for reading a csv file and creating a flat file, suggest if this script can be optimized #---------------- FILENAME="$1" SCRIPT=$(basename $0) #-----------------------------------------// function usage { echo "\nUSAGE: $THIS_SCRIPT file_to_process\n"... (3 Replies)
Discussion started by: mprakasheee
3 Replies

6. Shell Programming and Scripting

Reading from a CSV and writing in same CSV file

Hi, I am tryng to read from a csv file and based on some grep command output I will modify one of the column in the same csv. Example:- Input CSV:- 20120829001415,noneAA,google.com 20120829001415,dfsafds,google.com 20120829001415,noneAA,google.com Intermediate Step:- If 2nd column of... (3 Replies)
Discussion started by: kmajumder
3 Replies

7. Shell Programming and Scripting

Reading a csv file using shell script

Hello All, I have a csv file that looks like below ProdId_A,3.3.3,some text,some/text,sometext_1.2.3 ProdId_B,3.3.3,some text,some/text,sometext_1.2.3 ProdId_C,3.3.3,some text,some/text,sometext_1.2.3 ProdId_A,6.6.6,some text,some/text,sometext_9.9.9 I will get ProdId from... (5 Replies)
Discussion started by: anand.shah
5 Replies

8. Shell Programming and Scripting

Reading last line of a CSV file

Hi I have a file which I am reading line by line and processing it. But the last line is not getting read in the file loop until I put an enter in the end. #!/bin/ksh -p v_org_id=${P1} FILE=${P2} NEW_FILE_NAME=$APPLPTMP/b1.txt BAKIFS=$IFS IFS=$'\n' exec 0<"$FILE" echo "File to be... (2 Replies)
Discussion started by: Chinky23
2 Replies

9. Shell Programming and Scripting

Reading the value of particular column from csv file

Hi Folks, I have the below csv file which is comma delimited , now from this file i need to read the value of the column der_id and then want to create a separate text file which will contain the value of the column der_id only please advise how to read the value of the column der_id and then... (3 Replies)
Discussion started by: punpun66
3 Replies

10. UNIX for Beginners Questions & Answers

1. This will insert the records into db table by reading from ta csv file

I have this code with me but the condition is If any of the mandatory columns are null then entire file will be rejected. LOAD DATA infile ' ' #specifies the name of a datafile containing data that you want to load BADFILE ' ' #specifies the name of... (1 Reply)
Discussion started by: raka123
1 Replies
funtablerowget(3)						SAORD Documentation						 funtablerowget(3)

NAME
FunTableRowGet - get Funtools rows SYNOPSIS
#include <funtools.h> void *FunTableRowGet(Fun fun, void *rows, int maxrow, char *plist, int *nrow) DESCRIPTION
The FunTableRowGet() routine retrieves rows from a Funtools binary table or raw event file, and places the values of columns selected by FunColumnSelect() into an array of user structs. Selected column values are automatically converted to the specified user data type (and to native data format) as necessary. The first argument is the Fun handle associated with this row data. The second rows argument is the array of user structs into which the selected columns will be stored. If NULL is passed, the routine will automatically allocate space for this array. (This includes proper allocation of pointers within each struct, if the "@" pointer type is used in the selection of columns. Note that if you pass NULL in the second argument, you should free this space using the standard free() system call when you are finished with the array of rows.) The third maxrow argument specifies the maximum number of rows to be returned. Thus, if rows is allocated by the user, it should be at least of size maxrow*sizeof(evstruct). The fourth plist argument is a param list string. Currently, the keyword/value pair "mask=transparent" is supported in the plist argument. If this string is passed in the call's plist argument, then all rows are passed back to the user (instead of just rows passing the filter). This is only useful when FunColumnSelect() also is used to specify "$region" as a column to return for each row. In such a case, rows found within a region have a returned region value greater than 0 (corresponding to the region id of the region in which they are located), rows passing the filter but not in a region have region value of -1, and rows not passing any filter have region value of 0. Thus, using "mask=transparent" and the returned region value, a program can process all rows and decide on an action based on whether a given row passed the filter or not. The final argument is a pointer to an int variable that will return the actual number of rows returned. The routine returns a pointer to the array of stored rows, or NULL if there was an error. (This pointer will be the same as the second argument, if the latter is non-NULL). /* get rows -- let routine allocate the row array */ while( (buf = (Ev)FunTableRowGet(fun, NULL, MAXROW, NULL, &got)) ){ /* process all rows */ for(i=0; i<got; i++){ /* point to the i'th row */ ev = buf+i; /* rearrange some values. etc. */ ev->energy = (ev->pi+ev->pha)/2.0; ev->pha = -ev->pha; ev->pi = -ev->pi; } /* write out this batch of rows */ FunTableRowPut(fun2, buf, got, 0, NULL); /* free row data */ if( buf ) free(buf); } As shown above, successive calls to FunTableRowGet() will return the next set of rows from the input file until all rows have been read, i.e., the routine behaves like sequential Unix I/O calls such as fread(). See evmerge example code for a more complete example. Note that FunTableRowGet() also can be called as FunEventsGet(), for backward compatibility. SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funtablerowget(3)
All times are GMT -4. The time now is 05:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy