我有类似这样的记录,有时有重复的body {
margin: 0;
padding: 0;
}
.gallery-item-wrap {
width: 70vw;
margin: 0 auto;
}
figure {
margin: 0;
}
figure img {
width: 100%;
height: auto;
}
figure.zoomed {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 99;
overflow: hidden;
}
figure.zoomed img {
transform: scale(2);
}
条目,尽管有不同的$('.zoom').click(function () {
$(this).toggleClass('zoomed');
});
$('.zoom')
.on('mousemove', function(e){
$(this).children('.zoom img').css({'transform-origin': ((e.pageX - $(this).offset().left) / $(this).width()) * 100 + '% ' + ((e.pageY - $(this).offset().top) / $(this).height()) * 100 +'%'});
})
。
例如,srcPath
在一条记录中出现3次,而references
不同。
我想打印一次唯一的/content/dam/foo/about-bar/photos/rayDavis.PNG
和相关的references
。
我也有空记录,
srcPath
我不想看到那些。
我真的很想使用csv:
references
,也许是一个不同的字段,例如{
"pages": []
}
,以及第一个srcPath
,第二个published
,第三个reference
等-关联的{{1 }}数组作为同一行上连续的逗号分隔值,例如:
reference
换句话说,具有关联的reference
的唯一references
条目。
我想如果我也想要"/content/dam/foo/about-bar/pdf/theplan.pdf", true, "/content/foo/en/about-bar/the-plan-and-vision/jcr:content/content2/image/link", "/content/foo/en/about-bar/the-plan-and-vision/jcr:content/content2/textboximg/boxFtr", "/content/foo/en/about-bar/the-plan-and-vision/jcr:content/content1/textboximg/text"
"/content/dam/foo/about-bar/photos/rayDavis.PNG", true, "/content/foo/en/about-bar/jcr:content/content1B/promos_1/image/fileReference", "/content/foo/en/about-bar/monkey-development/tales-of-giving/ray-moose-davis/jcr:content/content1/textboximg/fileReference", "/content/foo/en/about-bar/monkey-development/tales-of-giving/jcr:content/content1/textboximg_2/fileReference"
"/content/dam/foo/about-bar/pdf/foo_19thNewsletter.pdf", true, "/content/foo/en/gremlins/stay-tuned/jcr:content/content3/textboximg/text"
"/content/dam/foo/about-bar/pdf/barNews_fall1617.pdf", true, "/content/foo/en/gremlins/jcr:content/content2C/textboximg_114671747/text", "/content/dam/foo/about-bar/pdf/barNews_fall1617.pdf", "/content/foo/en/gremlins/stay-tuned/jcr:content/content3/textboximg_0/text"
,我将不能在csv中有唯一的srcPath
行?
数据:
references
答案 0 :(得分:1)
您可以使用以下内容:
jq --raw-output '.pages | group_by(.srcPath)[] | [.[0].srcPath, .[0].published, .[].references[]] | @csv'
我们将页面按srcPath分组,并将每个组映射到一个数组,该数组包含srcPath和该组的第一个元素的发布以及该组的每个元素的引用。这些数组中的每个数组都将在CSV结果中排成一行。