xsv icon indicating copy to clipboard operation
xsv copied to clipboard

search or filter multi value

Open Grummfy opened this issue 3 years ago • 2 comments

Hello, I have two "big" csv files : A & B

  • A have header, B have no headers
  • A have a column "Id", B have the second column that have some of the "Id" from A in it.

I would like to split theses files into smaller chunks. But I would like that there is still some consistency between chunks. So I would like that if I have a chunk n, all "Id" from An that exist in B would be present in Bn.

So I see the split, I see the order & index, I see the select and the search. So every of theses element will help. But search only allow to look for one value. For now, the only way I see to do this, is to select in B the value that will be exist in An and push it inside the Bn, but this seems not very helpfull.

So did you see a way to do this? For me it seems to me a basic behaviour?

Grummfy avatar Dec 02 '20 09:12 Grummfy

I don't understand what you want. Please show what you've tried, some input, the actual output and the output you want.

BurntSushi avatar Dec 02 '20 11:12 BurntSushi

No problem

So here is an example

A.csv

Id,name,value
1,foo,42
5,bar,105
42,stuff,123456

B.csv

hello,2020-01-01,5
baz,2020-01-01,5
yoloooo,2020-05-20,1
funnn,2020-05-20,42

So the expected output would be Split A in chunks A_0.csv

Id,name,value
1,foo,42
5,bar,105

A_0.csv

Id,name,value
1,foo,42
42,stuff,123456

split B, related to field Id in A that match third column of B B_0.csv

hello,2020-01-01,5
baz,2020-01-01,5
yoloooo,2020-05-20,1

B_1.csv

funnn,2020-05-20,42

so the command will be

xsv split -s 2 A.csv

And then I will do

xsv search -n -s 3 1 B.csv >> B_0.csv
xsv search -n -s 3 5 B.csv >> B_0.csv
xsv search -n -s 3 42 B.csv >> B_1.csv

So having something like xsv search -n -s 3 --value=1 --value=5 B.csv >> B_0.csv would be nice

Grummfy avatar Dec 03 '20 12:12 Grummfy