Sponsored Content
Top Forums Shell Programming and Scripting CSV Split field to check multiple codes Post 302965683 by SDohmen on Tuesday 2nd of February 2016 04:27:52 AM
Old 02-02-2016
Quote:
Originally Posted by RudiC
Try
Code:
awk  ' 
BEGIN           {FS = OFS = ";"
                 print "ean;sku;pps_reference;mpn;stock;price;manufacturer"
                }
                {gsub (/ /, "", $1)
                }
NR == FNR       {for (n = split($1, T, ","); n > 0; n--) S[T[n]]=$2
                 next
                }
                {for (n = split($1, T, ","); n > 0; n--) if (T[n] in S) {$2 = S[T[n]] OFS $2
                                                                         print
                                                                         next
                                                                        }
                }
' file[12]
ean;sku;pps_reference;mpn;stock;price;manufacturer
4716659648413;90IG00W0-BM3G20;49200;90IG00W0-BM3G20;8;267,23;ASUS
4716659214199;90-IGY7002M00-3PA0;74277;90-IGY7002M01-3PA0-;7;217,56;ASUS
5703887123507;nd1235458;93631;128470701;5;209,16;Nilfisk
0024066040145,0240660401452;P00000052;887024;YDUVP052;50;15.86;Hoya

Sorry for the late reply but i had no chance to test it earlier.

I just changed the code to the one above and it works flawlesly. I am very grateful for the help.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Matching lines across multiple csv files and merging a particular field

I have about 20 CSV's that all look like this: "","","","","","","","","","","","","","","",""What I've been told I need to produce is the exact same thing, but with each file now containing the start_code from every other file where the email matches. It doesn't matter if any of the other... (1 Reply)
Discussion started by: Demosthenes
1 Replies

2. Shell Programming and Scripting

Field validations in multiple files CSV

Hi, I am regular reader of this forum. My advanced thanks to everyone. Below given are the sample files INDATA (Main data) Fild1Çfld2Çfld3….. Fild1Çfld2Çfld3….. Fild1Çfld2Çfld3….. Fild1Çfld2Çfld3….. Fild1Çfld2Çfld3….. . . N records (140000) eg GRPDATA (Reference file) (2 Replies)
Discussion started by: hyperion.krish
2 Replies

3. Shell Programming and Scripting

awk to split one field and print the last two fields within the split part.

Hello; I have a file consists of 4 columns separated by tab. The problem is the third fields. Some of the them are very long but can be split by the vertical bar "|". Also some of them do not contain the string "UniProt", but I could ignore it at this moment, and sort the file afterwards. Here is... (5 Replies)
Discussion started by: yifangt
5 Replies

4. Shell Programming and Scripting

Split a file into multiple files based on field value

Hi, I've one requirement. I have to split one comma delimited file into multiple files based on one of the column values. How can I achieve this Unix Here is the sample data. In this case I have split the files based on date column(c4) Input file c1,c2,c3,c4,c5... (1 Reply)
Discussion started by: manasvi24
1 Replies

5. Shell Programming and Scripting

How to split file into multiple files using awk based on 1 field in the file?

Good day all I need some helps, say that I have data like below, each field separated by a tab DATE NAME ADDRESS 15/7/2012 LX a.b.c 15/7/2012 LX1 a.b.c 16/7/2012 AB a.b.c 16/7/2012 AB2 a.b.c 15/7/2012 LX2 a.b.c... (2 Replies)
Discussion started by: alexyyw
2 Replies

6. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

7. Shell Programming and Scripting

Split a .csv File into Multiple Files

Hi guys, I have a requirement where i need to split a .csv file into multiple files. Say for example i have data.csv file and i have splitted that into multiple files based on some conditions i.e first file should have 100, last file 50 and other files 1000 each. Am passing the values in... (2 Replies)
Discussion started by: azherkn3
2 Replies

8. 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

9. Shell Programming and Scripting

awk - CSV file - field with single or multiple spaces

Hi, In a csv file, I want to select records where first column has zero or multiple spaces. Eg: abc.csv ,123,a ,22,b ,11,c a,11,d So output should be: ,123,a ,22,b ,11,c Please advise (5 Replies)
Discussion started by: vegasluxor
5 Replies
Finance::Quote::TSP(3pm)				User Contributed Perl Documentation				  Finance::Quote::TSP(3pm)

NAME
Finance::Quote::TSP - Obtain fund prices for US Federal Government Thrift Savings Plan SYNOPSIS
use Finance::Quote; $q = Finance::Quote->new; %info = Finance::Quote->fetch("tsp","c"); #get value of C "Common Stock Index Investment" Fund DESCRIPTION
This module fetches fund information from the "Thrift Savings Plan" http://www.tsp.gov using its fund prices page https://www.tsp.gov/investmentfunds/shareprice/sharePriceHistory.shtml The quote symbols are C common stock fund F fixed income fund G government securities fund I international stock fund S small cap stock fund L2020 lifecycle fund year 2020 L2030 lifecycle fund year 2030 L2040 lifecycle fund year 2040 L2050 lifecycle fund year 2050 LINCOME lifecycle income fund LABELS RETURNED
The following labels may be returned by Finance::Quote::TSP : name eg. "Common Stock Index Investment Fund" date latest date, eg. "21/02/10" isodate latest date, eg. "2010-02-21" last latest price, eg. "16.1053" close previous day's price nav same as "last" currency "USD" method "tsp" "nav" is the same as "last" since the funds are quoted at their net asset value. SEE ALSO
Thrift Savings Plan, http://www.tsp.gov perl v5.14.2 2014-03-03 Finance::Quote::TSP(3pm)
All times are GMT -4. The time now is 05:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy