gocsv icon indicating copy to clipboard operation
gocsv copied to clipboard

Join Subcommand Problem

Open happydentist opened this issue 3 years ago • 1 comments

I use gocsv join subcommand with 2 csv files, but only for one column condition. If more than one column to be join with, it failed. How to join 2 csv files with multiple columns condition?

happydentist avatar Aug 08 '21 04:08 happydentist

@happydentist, you can use the add command and a template to create a composite column of the two columns you want to join on, for both files:

gocsv add -name 'Join_col' - t '{{ .Col_A }} --- {{ .Col_B }}' File1.csv
gocsv add -name 'Join_col' - t '{{ .Col_C }} --- {{ .Col_D }}' File2.csv
gocsv join -c 'Join_col' File1.csv File2.csv

zacharysyoung avatar May 10 '22 17:05 zacharysyoung