Topic
Summary
- How to filter the data by the partial filename of a link or a list of links?
DQL10
: Using nested list items=> A root list item starts withquestion::
and each of its children starts withanswer::
.
the note structure: case_FLST_LD
Summary
case_FLST_LD-DDD: use file.lists where the root L contains children and L.children contains three different DVIFs
FLST: Use file.lists
L : a root element of file.lists
D: DVIF
-DDD: L.children contains three different DVIFs (for example)
Take the following file as an example.
-DDD: L.children.answer, L.children.outlinks, L.children.tags
---
Date: 1991-04-01
---
#questions
- question::Question # 1?
- answer::Answer 1.1. [[another Person]], [[some Person]] #Test/d01
Test
Summary
- dataview: v0.5.55
Input
Summary
dictionary files: for the DQL10
- Location: “100_Project/02_dataview/Q18_QAA/Q18_test_data”
folder: 03
- filename :
dic_19910301
---
Date: 1991-03-01
---
#questions
- question::Question # 1?
- answer::Answer 1.1. [[some Person]]
- answer::Answer 1.2. [[another Person]]
- question::Question # 2?
- answer::Answer 2.1. [[Person J]]
- answer::Answer 2.2. [[Person K]]
folder: 04_a_root_list_item_and_its_clild
- filename :
dic_19910401
---
Date: 1991-04-01
---
#questions
- question::Question # 1?
- answer::Answer 1.1. [[another Person]], [[some Person]] #Test/d01
folder: 05_a_root_list_item_and_its_children
- filename :
dic_19910501
---
Date: 1991-05-01
---
#questions
- question::Question # 1?
- answer::Answer 1.1. [[Person J]], [[some Person]]
- answer::Answer 1.2. [[Person K]], [[another Person]]
folder: 06_children_null
- filename :
dic_19910601
---
Date: 1991-06-01
---
#questions
- question::Question # 1?
- answer::
- answer::
folder: 07_children_undefined
- filename :
dic_19910701
---
Date: 1991-07-01
---
#questions
- question::Question # 1?
folder: 08_undefined
- filename :
dic_19910801
---
Date: 1991-08-01
---
#questions
folder: 09_excluding_answer_without_links
- filename :
dic_19910901
---
Date: 1991-09-01
---
#questions
- question::Question # 1?
- answer::Answer 1.1. "another Person"
- answer::Answer 1.2. "some Person"
folder: 10_excluding_task_items
- filename :
dic_19911001
---
Date: 1991-10-01
---
#questions
- [ ] question::Question # 1?
- [ ] answer::Answer 1.1. [[another Person]], [[some Person]] #Test/d01
DQL10_filter_by_partial_filename_of_a_link_or_a_list_of_links: case_FLST_LD-DDD
Summary
Main DQL
Code Name | Data type | Group By | Purposes | Remark |
---|---|---|---|---|
DQL10_filter_by _partial_filename _of_a_link _or_a_list_of_links |
LC.outlinks :a link or a list of links |
no | 0.To require the note structure like case_FLST_LD-DDD 1.To filter the data by the partial filename of a link or a list of links |
1.The Regular Expression declared as a variable like s_filename_of_link in the DQL10 is based on the DQL10 in the following topic.- Solutions: by Justdoitcc 2.The Regular Expression declared as a variable like answer_without_outlinks in the DQL10 is based on the DQL10 in the following topic.- Solutions: by Justdoitcc |
Notes
Summary
Q1: How to modify the following code without filtering the data by answer_without_outlinks
?
Summary_Q1
Original Example: Q1 (To be modified)
- To filter the data by
answer_without_outlinks
```dataview
FLATTEN regexreplace(LC.answer, "(\s+\[\[.+\]\].*$)", "") AS answer_without_outlinks
WHERE contains(answer_without_outlinks , "1.1.") OR contains(answer_without_outlinks , "1.2.")
```
A1_11:
Another Example: A1_11
- Not to filter the data by
answer_without_outlinks
: remove the code as mentioned above.
```dataview
```
Q2: How to filter the data by the partial filename of a link(or a list of links) without using the FLATTEN operator?
- To filter the data by partial filename of a link(or a list of links)
Summary_Q2
Original Example: Q2 (To be explained)
```dataview
FLATTEN map(LC.outlinks, (e) => regexreplace(meta(e).path, "^(.*/)(.+)(\.md)$", "$2")) AS s_filename_of_link
WHERE contains(s_filename_of_link , "another")
```
A2: (The same codes)
Another Example: A2_21
```dataview
WHERE filter(LC.outlinks, (e) => contains(regexreplace(meta(e).path, "^(.*/)(.+)(\.md)$", "$2") , "another"))
```
Another Example: A2_22
```dataview
WHERE any(LC.outlinks, (e) => contains(regexreplace(meta(e).path, "^(.*/)(.+)(\.md)$", "$2") , "another"))
```
Another Example: A2_23
```dataview
WHERE !none(LC.outlinks, (e) => contains(regexreplace(meta(e).path, "^(.*/)(.+)(\.md)$", "$2") , "another"))
```
Q3: How to filter the data by link
(or string
) of a link(or a list of links)?
- To filter the data by
link
(orstring
) of a link(or a list of links)
DQL Comments
Summary
# | Code | Data type | In English | Remark |
---|---|---|---|---|
1 | TABLE WITHOUT ID | 1.1 To display the result as a table 1.2 Not to display the default ID columns, File or Group |
||
2 | file.link AS “File”, …, s_filename_of_link AS “s_filename_of_link” | 2.1 To display the content of a field variable file.link ,… 2.2 To display the field label as “File”,… |
||
3 | ||||
4 | FROM “100_Project/02_dataview/Q18_QAA/Q18_test_data” AND #questions | FROM the folder and the tags | ||
5 | ||||
6 | FLATTEN file.lists AS L | a list=>a non-list | 6.1 To break up a list like file.lists in a file into each individual element in a file 6.2 let L = each element of file.lists of each page; |
|
7 | WHERE !L.task | To gather list items | To exclude task items in the note dic_19911001 |
|
8 | WHERE !L.parent AND L.question != null AND L.children | 8.1 To gather root items 8.2 L.question does not strictly equal null 8.3 L.children is not an empty array |
||
9 | ||||
10 | FLATTEN L.children AS LC | a list=>a non-list | 10.1 To break up a list like L.children in a file into each individual element in a file 10.2 let LC = L.children; |
|
11 | WHERE LC.answer != null AND LC.outlinks | 11.1 LC.answer does not strictly equal null 11.2 LC.outlinks is not an empty array |
||
12 | ||||
13 | FLATTEN map(LC.outlinks, (e) => regexreplace(meta(e).path, “^(.*/)(.+)(.md)$”, “$2”)) AS s_filename_of_link | a list=>a non-list | 13.1 To break up a list like LC.outlinks in a file into each individual element in a file 13.2 let s_filename_of_link = regexreplace... ; |
13.2 To get the filename from s_filename_of_link that is a copy of an element of LC.outlinks |
14 | WHERE contains(s_filename_of_link , “another”) | s_filename_of_link contains “another” |
To filter the data by partial filename of a link(or a list of links) | |
15 | ||||
16 | FLATTEN regexreplace(LC.answer, “(\s+[[.+]].*$)”, “”) AS answer_without_outlinks | let answer_without_outlinks = regexreplace... ; |
To remove the LC.outlinks string from answer_without_outlinks that is a copy of LC.answer |
|
17 | WHERE contains(answer_without_outlinks , “1.1.”) OR contains(answer_without_outlinks , “1.2.”) | 17.1 answer_without_outlinks contains “1.1.”17.2 answer_without_outlinks contains “1.2.” |
To filter the data by answer_without_outlinks |
|
18 | ||||
19 | SORT file.link ASC | To sort by file.link in ascending order |
Code DQL10_filter_by_partial_filename_of_a_link_or_a_list_of_links: case_FLST_LD-DDD
Summary_code
title: DQL10_filter_by_partial_filename_of_a_link_or_a_list_of_links=>0.To require the note structure like case_FLST_LD-DDD
collapse: close
icon:
color:
```dataview
TABLE WITHOUT ID
file.link AS "File",
L.question AS "Question",
LC.answer AS "Answer",
answer_without_outlinks AS "Answer_without_outlinks",
LC.outlinks AS "LC_outlinks",
s_filename_of_link AS "s_filename_of_link"
FROM "100_Project/02_dataview/Q18_QAA/Q18_test_data" AND #questions
FLATTEN file.lists AS L
WHERE !L.task
WHERE !L.parent AND L.question != null AND L.children
FLATTEN L.children AS LC
WHERE LC.answer != null AND LC.outlinks
FLATTEN map(LC.outlinks, (e) => regexreplace(meta(e).path, "^(.*/)(.+)(\.md)$", "$2")) AS s_filename_of_link
WHERE contains(s_filename_of_link , "another")
FLATTEN regexreplace(LC.answer, "(\s+\[\[.+\]\].*$)", "") AS answer_without_outlinks
WHERE contains(answer_without_outlinks , "1.1.") OR contains(answer_without_outlinks , "1.2.")
SORT file.link ASC
```
Screenshots(DQL10)
Reference
Summary
Q88_Links
- Q88_Links: Solutions
Q92_FileLists > DQL10
- Q92_FileLists:Part01 Solutions with input