How to compare and sort 2 csv's to show difference

后端 未结 4 2046
我在风中等你
我在风中等你 2021-01-24 18:28

Hi I have 2 csv\'s in the following format, (basically a list of email and the number of times we have been emailed by that sender):

file1.csv

Email,Val         


        
4条回答
  •  無奈伤痛
    2021-01-24 19:16

    using join program

    join -t, -o0,1.2,2.2 -a1 -a2 <(sort 

    otherwise if files are already sorted and contain the same entries with bash builtins

    while
        IFS=, read -u3 em1 val1
        IFS=, read -u4 em2 val2
        [[ -n $em1 ]] && [[ -n $em2 ]]
    do
        if [[ $em1 = $em2 ]]; then
            echo "$em1,$val1,$val2"
        else
            echo "ERROR: $em1 <> $em2"
        fi
    done 3

提交回复
热议问题