Topic
Summary
- How to filter the data by the filename of a link?
Structures
Summary
case_YAML_Y-YYY
The Note Structure
case_YAML_Y-YYY: To use nested YAML fields where the single root YAML contains multiple correlated sub-YAMLs that are repeated or not
YAML: To use YAML
Y: the single root YAML
-YYY: multiple correlated sub-YAMLs that are repeated or not
Example10: the sub-YAMLs are not repeated
Take the following file as an example.
-YYY: purchases.store, purchases.item, purchases.comments
---
date: 1992-06-01
purchases:
- store: "[[some store]]"
item: some item
comments: comments
---
The Data Structure
let slice_pages = {
date: "1992-06-01T00:00:00.000Z",
purchases: [
{
store: "[[some store]]",
item: "some item",
comments: "comments",
},
],
};
Example11: the sub-YAMLs are repeated
Take the following file as an example.
-YYY: purchases.store, purchases.item, purchases.comments
---
date: 1992-03-01
purchases:
- store: "[[some store]]"
item: some item
comments: comments
- store: "[[another store]]"
item: another item
comments: other comments
---
The Data Structure
let slice_pages = {
date: "1992-03-01T00:00:00.000Z",
purchases: [
{
store: "[[some store]]",
item: "some item",
comments: "comments",
},
{
store: "[[another store]]",
item: "another item",
comments: "other comments",
},
],
};
Test
Summary
- dataview: v0.5.46
input
Summary
dictionary files: for DQL10
- Location: “100_Project/02_dataview/Q17_Purchases/Q17_test_data”
03
- filename :
dic_19920301
---
date: 1992-03-01
purchases:
- store: "[[some store]]"
item: some item
comments: comments
- store: "[[another store]]"
item: another item
comments: other comments
---
04
- filename :
dic_19920401
---
date: 1992-04-01
purchases:
- store: "[[some store]]"
item: apples
comments:
- store: "[[some store]]"
item: oranges
comments:
---
05
- filename :
dic_19920501
---
date: 1992-05-01
purchases:
- store: "[[another store]]"
item: potatoes, potatoes
comments:
- store: "[[another store]]"
item: a very big watermelon
comments:
---
06_a_root_YAML_and_its_children
- filename :
dic_19920601
---
date: 1992-06-01
purchases:
- store: "[[some store]]"
item: some item
comments: comments
---
07_including_an_empty_record
- filename :
dic_19920701
---
date: 1992-07-01
purchases:
- store: "[[some store]]"
item: some item
comments: comments
- store:
item:
comments:
---
08_null
- filename :
dic_19920801
---
date: 1992-08-01
purchases:
---
09_undefined
- filename :
dic_19920901
---
date: 1992-09-01
---
10_excluding_store_not_link
- filename :
dic_19921001
---
date: 1992-10-01
purchases:
- store: "another store"
item: another item
comments: comments
---
DQL10_filter_by_filename_of_a_link: case_YAML_Y-YYY
Summary
Main DQL
Code Name | Data type | Group By | Purposes | Remark |
---|---|---|---|---|
DQL10_filter_by _filename_of_a_link |
P.store :a link |
no | 0.To require the note structure like case_YAML_Y-YYY 1.To filter by purchases 2.To break up a list like purchases in a file into each individual P in a file and let P = each element of purchases of each page 3.To filter by P and P.store 4.To define a field variable s_filename_of_link 5.To filter by s_filename_of_link 6.To sort by date in descending order 7.To display the result as a table |
The Regular Expression in the DQL10 is based on the DQL10 in the following topic. - Solutions: by Justdoitcc |
Code DQL10_filter_by_filename_of_a_link: case_YAML_Y-YYY
Summary_code
title: DQL10_filter_by_filename_of_a_link =>0.To require the note structure like case_YAML_Y-YYY 1.To filter by `purchases` 2.To break up a list like `purchases` in a file into each individual `P` in a file and let P = each element of `purchases` of each page 3.To filter by `P` and `P.store` 4.To define a field variable `s_filename_of_link` 5.To filter by `s_filename_of_link` 6.To sort by `date` in descending order 7.To display the result as a table
collapse: close
icon:
color:
```dataview
TABLE WITHOUT ID
file.link AS "File",
P.store AS "store",
P.item AS "item",
P.comments AS "comments",
s_filename_of_link AS "filename_of_store"
FROM "100_Project/02_dataview/Q17_Purchases/Q17_test_data"
WHERE purchases != null
FLATTEN purchases AS P
WHERE P != null AND P.store != null
FLATTEN regexreplace(meta(P.store).path, "^(.*/)(.+)(\.md)$", "$2") AS s_filename_of_link
WHERE contains(s_filename_of_link, "another store")
SORT date DESC
```