Sponsored Content
Top Forums Shell Programming and Scripting UNIX append field with comparing fields from multiple column Post 302852085 by nike27 on Tuesday 10th of September 2013 12:34:06 PM
Old 09-10-2013
Question UNIX append field with comparing fields from multiple column

I have a csv dump from sql server that needs to be converted so it can be feed to another program. I already sorted on field 1 but there are multiple columns with same field 1 where it needs to be compared against and if it is same then append field 5.

i.e from

Code:
ANG SJ,0,B,LC22,LC22(0)
BAT SJ,0,B,LC22,LC22(0)
BAT SJ,0,B,LC22,LC22(0)
BGA SJ,40000,B,SL22,SL22(40000)
BGA SJ,40000,B,SL22,SL22(40000)
BGA SJ,50000,B,SL22,SL22(50000)
BHW PW,152000,B,EX22,EX22(152000)
BKIR ID,15000000,B,GSI,GSI(15000000)
BKIR ID,15000000,B,GSI,GSI(15700000)
BKIR ID,15000000,B,GSI,GSI(15000000)
BKIR ID,15900000,B,GSI,GSI(15900000)
EBS AV,0,B,LC22,LC22(0)
EBS AV,1,B,LC22,LC22(1)
EBS AV,2,B,LC22,LC22(2)
EBS AV,3,B,LC22,LC22(3)
EBS AV,4,B,LC22,LC22(4)

it needs to be converted to following:

Code:
ANG SJ,0,B,LC22,LC22(0)
BAT SJ,0,B,LC22(0)|LC22(0)
BGA SJ,40000,B,SL22(40000)|SL22(40000)|SL22(50000)
BHW PW,152000,B,EX22,EX22(152000)
BKIR ID,15000000,B,GSI(15000000)|GSI(15700000)|(15000000)|(15900000)
EBS AV,0,B,LC22(0)|LC22(1)|LC22(2)|LC22(3)|LC22(4)

.

problem is sometime there is single filed 1 or it could be two or three or four times.

Last edited by nike27; 09-10-2013 at 01:37 PM.. Reason: fix typo
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to read and compare multiple fields in a column at the same time

Hi, Currently I am coding up a nasty way of reading file input using *cat* rather than *read*. My text input looks like TextA 100 TextB 110 TextC 120 Currently I am using cat |while read line to read the first column and second column fields. cat foo.txt|while read line do ... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

2. Shell Programming and Scripting

eAdd two fields in a column if their previous field values are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output file as follows If field3 in file1 is same as field3 in the next line then the field4 should add... (1 Reply)
Discussion started by: yerruhari
1 Replies

3. Shell Programming and Scripting

awk- comparing fields from the same column, finding discontinuities.

Hello, I have a file with two fields. The first field repeats itself for quite a while but the second field changes. What I want to do is to go through the first column until its value changes (and while it doesn't, verify that the second field is in a sequence from 0-15). Example input: ... (13 Replies)
Discussion started by: acsg
13 Replies

4. Shell Programming and Scripting

Compare a common field in two files and append a column from File 1 in File2

Hi Friends, I am new to Shell Scripting and need your help in the below situation. - I have two files (File 1 and File 2) and the contents of the files are mentioned below. - "Application handle" is the common field in both the files. (NOTE :- PLEASE REFER TO THE ATTACHMENT "Compare files... (2 Replies)
Discussion started by: Santoshbn
2 Replies

5. UNIX for Dummies Questions & Answers

Comparing multiple fields from 2 files uing awk

Hi I have 2 files as below File 1 Chr Start End chr1 120 130 chr1 140 150 chr2 130 140 File2 Chr Start End Value chr1 121 128 ABC chr1 144 149 XYZ chr2 120 129 PQR I would like to compare these files using awk; specifically if column 1 of file1 is equal to column 1 of file2... (7 Replies)
Discussion started by: sshetty
7 Replies

6. Shell Programming and Scripting

Join fields comparing 4 fields using awk

Hi All, I am looking for an awk script to do the following Join the fields together only if the first 4 fields are same. Can it be done with join function in awk?? a,b,c,d,8,,, a,b,c,d,,7,, a,b,c,d,,,9, a,b,p,e,8,,, a.b,p,e,,9,, a,b,p,z,,,,9 a,b,p,z,,8,, desired output: ... (1 Reply)
Discussion started by: aksijain
1 Replies

7. Shell Programming and Scripting

Awk: print lines with one of multiple pattern in the same field (column)

Hi all, I am new to using awk and am quickly discovering what a powerful pattern-recognition tool it is. However, I have what seems like a fairly basic task that I just can't figure out how to perform in one line. I want awk to find and print all the lines in which one of multiple patterns (e.g.... (8 Replies)
Discussion started by: elgo4
8 Replies

8. Shell Programming and Scripting

Single Field to multiple fields searching

I have a fileA with one column (1000 rows), and fileB with 26 columns(13000 rows). I need to search each value of fileA with fileB and return all the 26 values from FileB to a new file- File C if matches. The search value (from FileA) may present in any of the 26 values in FileB. This value is not... (7 Replies)
Discussion started by: vamsikrishna928
7 Replies

9. Shell Programming and Scripting

Append data with substring of nth column fields using awk

Hi guys, I have problem to append new data at the end of each line of the files where it takes whole value of the nth column. My expected result i just want to take a specific value only. This new data is based on substring of 11th, 12th 13th column that has comma seperated value. My code: awk... (4 Replies)
Discussion started by: null7
4 Replies

10. UNIX for Beginners Questions & Answers

How can I stack multiple (>1000) fields into one continuous field?

Hi, I'm struggling with a problem at the minute. Basically, I have a file with >1000 columns / fields (with headers), each containing a variable number of values. I would like to stack each column such that all the data appears in a single column, e.g. the first value of column 2 is moved to... (5 Replies)
Discussion started by: TAlcock
5 Replies
GSI GSS Assist Constants(3)					 globus gss assist				       GSI GSS Assist Constants(3)

NAME
GSI GSS Assist Constants - Enumerations enum globus_gsi_gss_assist_error_t { GLOBUS_GSI_GSS_ASSIST_ERROR_SUCCESS = 0, GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_ARGUMENTS = 1, GLOBUS_GSI_GSS_ASSIST_ERROR_USER_ID_DOESNT_MATCH = 2, GLOBUS_GSI_GSS_ASSIST_ERROR_IN_GRIDMAP_NO_USER_ENTRY = 3, GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_GRIDMAP = 4, GLOBUS_GSI_GSS_ASSIST_ERROR_INVALID_GRIDMAP_FORMAT = 5, GLOBUS_GSI_GSS_ASSIST_ERROR_ERRNO = 6, GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_INIT = 7, GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_WRAP = 8, GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_TOKEN = 9, GLOBUS_GSI_GSS_ASSIST_ERROR_EXPORTING_CONTEXT = 10, GLOBUS_GSI_GSS_ASSIST_ERROR_IMPORTING_CONTEXT = 11, GLOBUS_GSI_GSS_ASSIST_ERROR_INITIALIZING_CALLOUT_HANDLE = 12, GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_CALLOUT_CONFIG = 13, GLOBUS_GSI_GSS_ASSIST_CALLOUT_ERROR = 14, GLOBUS_GSI_GSS_ASSIST_GSSAPI_ERROR = 15, GLOBUS_GSI_GSS_ASSIST_GRIDMAP_LOOKUP_FAILED = 16, GLOBUS_GSI_GSS_ASSIST_BUFFER_TOO_SMALL = 17, GLOBUS_GSI_GSS_ASSIST_ERROR_CANONICALIZING_HOSTNAME = 18 } Enumeration Type Documentation enum globus_gsi_gss_assist_error_t GSI GSS Assist Error codes. Enumerator: GLOBUS_GSI_GSS_ASSIST_ERROR_SUCCESS Success. GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_ARGUMENTS No user entry in gridmap file. GLOBUS_GSI_GSS_ASSIST_ERROR_USER_ID_DOESNT_MATCH Error user ID doesn't match. GLOBUS_GSI_GSS_ASSIST_ERROR_IN_GRIDMAP_NO_USER_ENTRY Error with arguments passed to function. GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_GRIDMAP Error querying gridmap file. GLOBUS_GSI_GSS_ASSIST_ERROR_INVALID_GRIDMAP_FORMAT Invalid gridmap file format. GLOBUS_GSI_GSS_ASSIST_ERROR_ERRNO System Error. GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_INIT Error during context initialization. GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_WRAP Error during message wrap. GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_TOKEN Error with token. GLOBUS_GSI_GSS_ASSIST_ERROR_EXPORTING_CONTEXT Error exporting context. GLOBUS_GSI_GSS_ASSIST_ERROR_IMPORTING_CONTEXT Error importing context. GLOBUS_GSI_GSS_ASSIST_ERROR_INITIALIZING_CALLOUT_HANDLE Error initializing callout handle. GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_CALLOUT_CONFIG Error reading callout configuration. GLOBUS_GSI_GSS_ASSIST_CALLOUT_ERROR Error invoking callout. GLOBUS_GSI_GSS_ASSIST_GSSAPI_ERROR A GSSAPI returned an error. GLOBUS_GSI_GSS_ASSIST_GRIDMAP_LOOKUP_FAILED Gridmap lookup failure. GLOBUS_GSI_GSS_ASSIST_BUFFER_TOO_SMALL Caller provided insufficient buffer space for local identity. GLOBUS_GSI_GSS_ASSIST_ERROR_CANONICALIZING_HOSTNAME Failed to obtain canonical host name. Author Generated automatically by Doxygen for globus gss assist from the source code. Version 8.5 Mon Apr 30 2012 GSI GSS Assist Constants(3)
All times are GMT -4. The time now is 07:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy