What i'm trying to do is copy the first data from each row in the first column and put it into the hyperlink in the last column created
This is an example of a file i get each day. Let's call this file input.csv and i want to transform it into output.csv
P.S. The number of rows varies each day.
INPUT.CSV
number|name|age|gender
B24|mike|22|male
B65|john|45|male
B74|jane|29|female
This is how i want it to look like:
OUTPUT.CSV
number|name|age|gender|website
B24|mike|22|male|<a href=https://www.abcdef.com/query=B24>B24</a>
B65|john|45|male|<a href=https://www.abcdef.com/query=B65>B65</a>
B74|jane|29|female|<a href=https://www.abcdef.com/query=B74>B74</a>
To make it neater, i put some variables in place
test.sh
#!/bin/bash
NUMBER=(data from the "number" column of each corresponding row in the input.csv file)
URL=https://www.abcdef.com/search?query=$NUMBER
awk -F"|" 'BEGIN { OFS = "|" } {$5="<a href='$URL'>'$NUMBER'</a>"; print}' input.csv > output.csv
So far, i've been able to do this which just creates a new column and repeats the hyperlink all through the column and the result of my failed output is below:
FAILED RESULT
number|name|age|gender|<a href=https://www.abcdef.com/search?query=></a>
B65|john|45|male|<a href=https://www.abcdef.com/query=B65>B65</a>
B74|jane|29|female|<a href=https://www.abcdef.com/query=B74>B74</a>
Appreciate the help!