Find Corresponding Data in the One Table Using the Other Table

Problem description & analysis

Below is CSV file csv1.csv:

id,score

1,16

3,12

5,13

11,8

13,32

17,37

23,74

29,7

31,70

41,83

And here is another CSV file csv2.csv:

id

1

3

5

7

11

13

17

19

23

29

31

37

41

We are trying to search for corresponding data in csv1.csv using csv2.csv according to id values at command line, during which if an id in the second file does not exist in the first file, the corresponding value will be displayed as NAN. Below is the desired result:

1       16

3       12

5       13

7       NAN

11      8

13      32

17      37

19      NAN

23      74

29      7

31      70

37      NAN

41      83

Solution & explanation

Execute esprocx -r $select a.id as id, nvl(b.score, 'NAN') as score from csv2.csv a left join csv1.csv b on a.id = b.id from the command line to get the target result.

Q & A Collection

https://stackoverflow.com/questions/63588601/implementing-excel-vlookup-like-function-with-awk