Sponsored Content
Top Forums Shell Programming and Scripting Matching two fields in two csv files, create new file and append match Post 303023723 by RudiC on Friday 21st of September 2018 08:58:42 AM
Old 09-21-2018
Don't double post. What's new compared to your other thread https://www.unix.com/shell-programming-and-scripting/279906-comparing-two-columns-two-files-printing-third-based-match.html except the two (new?) input files? Your (new?) desired output doesn't seem to satisfy your specification, does it?


EDIT: adding
Code:
{gsub (/[ 	]*,[ 	]*/, ",")}

(note the <TAB> chars!) as the first statement in your awk script might help accomplish your task.

Last edited by RudiC; 09-21-2018 at 10:07 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create a CSV File by reading fields from separate files

SHELL SCRIPT Hi, I have 3 separate files within a folder. Every File contains data in a single column like File1 contains data mayank sushant dheeraj File2 contains DSA_AT MG_AT FLAT_09 File3 contains data 123123 232323 (2 Replies)
Discussion started by: mayanksargoch
2 Replies

2. Shell Programming and Scripting

Match data based on two fields, and append to a line

I need to write a program to do something like a 'vlookup' in excel. I want to match data from file2 based on two fields (where both match) in file1, and for matching lines, add the data from two of the fields from file2 to file1. If anyone knows something in perl or awk that can do this, I'd be... (20 Replies)
Discussion started by: jamessmith01
20 Replies

3. UNIX for Dummies Questions & Answers

Match values from 2 files and append certain fields

Hi, I need help on appending certain field in my file1.txt based on matched patterns in file2.txt using awk or sed. The blue color need to match with one of the data in field $2 in file2.txt. If match, BEGIN and FINISHED value in red will have a new value from field $3 and $4 accordingly. ... (1 Reply)
Discussion started by: redse171
1 Replies

4. Shell Programming and Scripting

Matching and Merging csv data fields based on a common field

Dear List, I have a file of csv data which has a different line per compliance check per host. I do not want any omissions from this csv data file which looks like this: date,hostname,status,color,check 02-03-2012,COMP1,FAIL,Yellow,auth_pass_change... (3 Replies)
Discussion started by: landossa
3 Replies

5. Shell Programming and Scripting

awk help: Match data fields from 2 files & output results from both into 1 file

I need to take 2 input files and create 1 output based on matches from each file. I am looking to match field #1 in both files (Userid) and create an output file that will be a combination of fields from both file1 and file2 if there are any differences in the fields 2,3,4,5,or 6. Below is an... (5 Replies)
Discussion started by: ambroze
5 Replies

6. Shell Programming and Scripting

Match columns from two csv files and update field in one of the csv file

Hi, I have a file of csv data, which looks like this: file1: 1AA,LGV_PONCEY_LES_ATHEE,1,\N,1,00020460E1,0,\N,\N,\N,\N,2,00.22335321,0.00466628 2BB,LES_POUGES_ASF,\N,200,200,00006298G1,0,\N,\N,\N,\N,1,00.30887539,0.00050312... (10 Replies)
Discussion started by: djoseph
10 Replies

7. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

8. UNIX for Beginners Questions & Answers

How to count lines of CSV file where 2 fields match variables?

I'm trying to use awk to count the occurrences of two matching fields of a CSV file. For instance, for data that looks like this... Joe,Blue,Yes,No,High Mike,Blue,Yes,Yes,Low Joe,Red,No,No,Low Joe,Red,Yes,Yes,Low I've been trying to use code like this... countvar=`awk ' $2~/$color/... (4 Replies)
Discussion started by: nmoore2843
4 Replies

9. Shell Programming and Scripting

awk to print fields that match using conditions and a default value for non-matching in two files

Trying to use awk to match the contents of each line in file1 with $5 in file2. Both files are tab-delimited and there may be a space or special character in the name being matched in file2, for example in file1 the name is BRCA1 but in file2 the name is BRCA 1 or in file1 name is BCR but in file2... (6 Replies)
Discussion started by: cmccabe
6 Replies

10. UNIX for Beginners Questions & Answers

Match Fields between two files, print portions of each file together when matched in ([g]awk)'

I've written an awk script to compare two fields in two different files and then print portions of each file on the same line when matched. It works reasonably well, but every now and again, I notice some errors and cannot seem to figure out what the issue may be and am turning to you for help. ... (2 Replies)
Discussion started by: jvoot
2 Replies
HXINCL(1)							  HTML-XML-utils							 HXINCL(1)

NAME
hxincl - expand included HTML or XML files SYNOPSIS
hxincl [ -x ] [ -f ] [ -s name=subst ] [ -s name=subst ]... [ -b base ] [ file-or-URL ] DESCRIPTION
The hxincl command copies an HTML or XML file to standard output, looking for comments with a certain structure. Such a comment is replaced by the file whose name is given as the attribute of the directive. For example: ...<!-- include "foo.html" -->... will be replaced by the content of the file foo.html. It is important to note that you must quote filenames if they contain white space. The comment is replaced by <!-- begin-include "foo.html" --> before the included text and <!-- end-include "foo.html" --> after it. These comments make it possible to run hxincl on the resulting file again to update the inclusions. Single quotes are allowed instead of double quotes. And if the file name contains no spaces, the quotes may also be omitted. OPTIONS
The following options are supported: -x Use XML conventions: empty elements are written with a slash at the end: <IMG />. -b base Sets the base URL for resolving relative URLs. By default the file given as argument is the base URL. -f Removes the comments after including the files. This means hxincl connot be run on the resulting file later to update the inclu- sions. (Mnemonic: final or frozen.) -s name=substitution Include a different file than the one mentioned in the directive. If the comment is <!-- include "name" --> the file substitution is included instead. The option -s may occur multiple times. OPERANDS
The following operand is supported: file-or-URL The name of an HTML or XML file or the URL of one. If absent, standard input is read instead. EXIT STATUS
The following exit values are returned: 0 Successful completion. > 0 An error occurred in the parsing of one of the HTML or XML files. ENVIRONMENT
To use a proxy to retrieve remote files, set the environment variables http_proxy or ftp_proxy. E.g., http_proxy="http://localhost:8080/" BUGS
Assumes UTF-8 as input. Doesn't expand character entities. Instead pipe the input through hxunent(1) and asc2xml(1) to convert it to UTF-8. Remote files (specified with a URL) are currently only supported for HTTP. Password-protected files or files that depend on HTTP "cookies" are not handled. (You can use tools such as curl(1) or wget(1) to retrieve such files.) SEE ALSO
asc2xml(1), hxnormalize(1), hxnum(1), hxprune(1), hxtoc(1), hxunent(1), xml2asc(1), UTF-8 (RFC 2279) 6.x 10 Jul 2011 HXINCL(1)
All times are GMT -4. The time now is 01:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy