Skip to content

How to join with an empty string? #321

Closed Answered by TomWright
bravoecho asked this question in Q&A
Discussion options

You must be logged in to vote

You should be able to use string() with no args to represent an empy string, however I wouldn't join with an empty string in this case, rather join with /.

E.g. This worked for me:

$ echo '{ "filename": "a.txt", "size": "1MB" }
{ "filename": "b.txt", "size": "0.5MB" }
{ "filename": "c.txt", "size": "1.5MB" }
{ "filename": "d.txt", "size": "0.3MB" }' | dasel -r json -w csv 'all().mapOf(file_path,join(/,string(/some/dir),filename),file_size,size).merge()'
file_path,file_size
/some/dir/a.txt,1MB
/some/dir/b.txt,0.5MB
/some/dir/c.txt,1.5MB
/some/dir/d.txt,0.3MB

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@TomWright
Comment options

Answer selected by TomWright
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants