Topic : The file.lists by example
- The file.lists by example - Chapter 1: using DQL to gather list items or task items under the specific heading
Summary
Q: How to gather list items or task items under the specific heading?
- How to gather list items where the heading contains “milestones”? (
DQL01
) - How to gather task items where the heading contains “tasks”? (
DQL03
) - How to gather list items where the heading contains “milestones” and to gather task items where the heading contains “tasks”? (
DQL05
) - How to gather list items where the heading contains “milestones” and to gather task items where the heading contains “tasks” and to groupBy file.link? (
DQL07
)
Q: How to distinguish list items from task items from the file.lists data?
Answers
- a list item: !L.task
- a task item: L.task
- L : each element of file.lists of each page
- No one can distinguish a list item from a task item from the value of L.text where L is an element of file.lists .
Q: How to display task items with the checkbox from non-groupBy data by using DQL?
Answers
- Use DQL
TABLE
- L : each element of file.lists of each page
TABLE WITHOUT ID
choice(L.task, "- [" + L.status + "] " + L.text, "- " + L.text) AS "milestones_or_tasks"
Q: How to display task items with the checkbox from groupBy data by using DQL?
- Use DQL
TABLE
- L : each element of file.lists of each page;
TABLE WITHOUT ID
map(rows.L, (L) => choice(L.task, "- [" + L.status + "] " + L.text, L.text)) AS "milestones_or_tasks"
Q: How to use FROM source
for best performance when using DQL?
- For best performance, it is recommended that each note is a desired note after using the
FROM source
because dataview will gather list items or task items into the file.lists data of each note which isFROM source
.- The DQL expression like
FROM source
is equal to the DVJS expression likelet pages = dv.pages(source);
- It gathers the following data.
- The
pages
array consists of eachpage
hash. - The plain
page
hash from a file is created by thedv.pages(source)
function and consists of three hashes : thepage.file
hash, the YAML fields and the Dataview inline fields. - The YAML fields is also stored in the page.file.frontmatter hash.
- Besides, the key/pair, the page.file.lists and its values, is an element of each
page
hash.
- The
- The DQL expression like
to modify(M1)
Original Example01: use Folders
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data"
Original Example02: use Folders and Tags
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data" AND #Project
Original Example03: use Tags
FROM #Project
Original Example04 : Single Files
- Inline DQL: To get file.path
path==[[dic_20060301]].file.path
//=>“100_Project/02_dataview/Q93_Tasks/Q93_test_data/03/dic_20060301.md”
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data/03/dic_20060301.md"
Wrong Examples :
- Performance issues :
- The following expression means that
let pages = dv.pages();
- It will gather list items or task items into the page.file.lists of each note but many of them are not necessary.
- The following expression means that
FROM ""
or
FROM "/"
Q: What does the following DQL statement mean?
FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type
Answers
-
FLATTEN file.lists AS L
- To break up a list like
file.lists
in a file into each individual element in a file - To define a field variable
L
as each element of page.file.lists of each note- let L = each element of file.lists of each page;
- To break up a list like
-
FLATTEN meta(L.header).subpath AS F_subpath
- let F_subpath = meta(L.header).subpath;
-
FLATTEN meta(L.header).type AS F_type
- let F_type = meta(L.header).type;
Q: How to use F_subpath
to filter by the specific heading when using DQL?
Case_01:
- filename :
dic_20060701
---
Date: 2006-07-01
---
#Project/P07
Areas:: #research
## input
### ?what: milestones, tasks!
- 2006-07-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- [ ] 2012-07-11 add this feature_A #Test/d01 [[Note P]] , [[Note Q]]
Answers: Case_01
WHERE contains(F_subpath, "what milestones tasks") AND F_type = "header"
or
WHERE F_subpath = "what milestones tasks" AND F_type = "header"
Case_02:
- filename :
dic_20060801
---
Date: 2006-08-01
---
#Project/P08
Areas:: #research
## input
### what: milestones, tasks!
- 2006-08-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- [ ] 2012-08-11 add this feature_A #Test/d01 [[Note P]] , [[Note Q]]
Answers: Case_02
WHERE contains(F_subpath, "what milestones tasks") AND F_type = "header"
or
WHERE F_subpath = "what milestones tasks" AND F_type = "header"
Case_03:
- filename :
dic_20060901
---
Date: 2006-09-01
---
#Project/P09
Areas:: #research
## input
### what milestones tasks:
- 2006-09-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- [ ] 2012-09-11 add this feature_A #Test/d01 [[Note P]] , [[Note Q]]
Answers: Case_03
WHERE contains(F_subpath, "what milestones tasks") AND F_type = "header"
or
WHERE F_subpath = "what milestones tasks" AND F_type = "header"
Case_04:
- filename :
dic_20061001
---
Date: 2006-10-01
---
#Project/P10
Areas:: #research
## input
### what milestones tasks
- 2006-10-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- [ ] 2012-10-11 add this feature_A #Test/d01 [[Note P]] , [[Note Q]]
Answers: Case_04
WHERE contains(F_subpath, "what milestones tasks") AND F_type = "header"
or
WHERE F_subpath = "what milestones tasks" AND F_type = "header"
Q: How to sort the task items which are classified as “T01”, “T02”, “T03” and “T99”?
- How to use nested
choice
? - How to define a field variable
F_prefix_text
as the expression likechoice...
by usingFLATTEN
?
Answers
TABLE WITHOUT ID
choice(L.task, "- [" + L.status + "] " + L.text, "- " + L.text) AS "milestones_or_tasks"
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data"
FLATTEN file.lists AS L
FLATTEN choice(contains(L.text, "✉️") OR (L.status = ">"),
"T01" + L.text,
choice(contains(L.text, "❗") OR (L.status = "!"),
"T02" + L.text,
choice(contains(L.text, "📐"), "T03" + L.text, "T99" + L.text))
) AS F_prefix_text
WHERE L.task and !L.completed
WHERE startswith(F_prefix_text, "T01") OR
startswith(F_prefix_text, "T02") OR
startswith(F_prefix_text, "T03")
SORT F_prefix_text ASC
Test
Summary
- dataview: v0.5.41
Input
Summary
dictionary files
- Location: “100_Project/02_dataview/Q93_Tasks/Q93_test_data”
- filename :
dic_20060301
---
Date: 2006-03-01
---
#Project/P03
Areas:: #research
## input
### input_m: milestones
- 2006-02-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- 2006-02-02 add this feature_B #Test/d02 [[Note J]]
- 2006-02-03 add this feature_C #Test/d03
- 2006-02-04 add this feature_D #Test/d04
- 2006-02-05 add this feature_E #Test/d05 [[Note K]]
- 2006-02-06 add this feature_F #Test/d06
- 2006-02-07 add this feature_G #Test/d07
- 2006-02-08 add this feature_H
- filename :
dic_20060401
---
Date: 2006-04-01
---
#Project/P04
Areas:: #mocap
## input
### Requirements
#### input_t: tasks
- [ ] ❗ New urgent task
- [ ] 📐 Example design task
- [ ] ✉️ Email PF re: Meeting list
- [ ] ❗ Brief → EC
- [!] ❗ Brief → EC (to do)
- [>] ✉️ Email PF re: Meeting list (to do)
- [x] It is done
- filename :
dic_20060501
---
Date: 2006-05-01
---
#Project/P05
Areas:: #research
## input
### input_m: milestones
- filename :
dic_20060601
---
Date: 2006-06-01
---
#Project/P05
Areas:: #mocap
## input
### Requirements
#### input_t: tasks
DQL01_flatten_fLists_and_display_list_items_under_the_heading_milestones
- To gather list items where the heading contains “milestones”
Summary
Main DQL
Code Name | Data type | Group By | Purposes | Remark |
---|---|---|---|---|
DQL01_flatten_fLists _and_display_list_items _under_the_heading_milestones |
file.lists | no | 1.To flatten file.lists 2.To gather list items where the heading contains “milestones” 3.To filter by L.text where it contains “feature_A” or “feature_B” or “feature_E” 4.To filter by L.tags where it contains “#Test/d01” or “#Test/d02” or “#Test/d05” 5.To filter by L.outlinks where it contains [[Note J]] or [[Note J]] 6.To display the result as a table [without the desired structure] |
Code DQL01_flatten_fLists_and_display_list_items_under_the_heading_milestones
- To gather list items where the heading contains “milestones”
Summary_code
title: DQL01_flatten_fLists_and_display_list_items_under_the_heading_milestones =>1.To flatten file.lists 2.To gather list items where the heading contains "milestones" 3.To filter by L.text where it contains "feature_A" or "feature_B" or "feature_E" 4.To filter by L.tags where it contains "#Test/d01" or "#Test/d02" or "#Test/d05" 5.To filter by L.outlinks where it contains \[\[Note J\]\] or \[\[Note J\]\] 6.To display the result as a table [without the desired structure]
collapse: close
icon:
color:
```dataview
TABLE WITHOUT ID
choice(L.task, "- [" + L.status + "] " + L.text, "- " + L.text) AS "milestones_or_tasks",
L.task AS "task",
L.status AS "status",
L.text AS "text",
F_subpath AS "F_subpath",
F_type AS "F_type",
file.link AS "File"
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data"
FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type
WHERE !L.task
WHERE contains(F_subpath, "milestones") AND F_type = "header"
WHERE contains(L.text, "feature_A") OR
contains(L.text, "feature_B") OR
contains(L.text, "feature_E")
WHERE contains(L.tags, "#Test/d01") OR
contains(L.tags, "#Test/d02") OR
contains(L.tags, "#Test/d05")
WHERE contains(L.outlinks, [[Note J]]) OR
contains(L.outlinks, [[Note K]])
SORT file.name ASC
```
Screenshots(DQL01)
DQL03_flatten_fLists_and_display_task_items_under_the_heading_tasks
- To gather task items where the heading contains “tasks”
Summary
Main DQL
Code Name | Data type | Group By | Purposes | Remark |
---|---|---|---|---|
DQL03_flatten_fLists _and_display_task_items _under_the_heading_tasks |
file.lists | no | 1.To flatten file.lists 2.To gather task items where the heading contains “tasks” 3.To filter by L.text where it contains “urgent” or “Email” or “design” 4.To display the result as a table [without the desired structure] |
Code DQL03_flatten_fLists_and_display_task_items_under_the_heading_tasks
- To gather task items where the heading contains “tasks”
Summary_code
title: DQL03_flatten_fLists_and_display_task_items_under_the_heading_tasks =>1.To flatten file.lists 2.To gather task items where the heading contains "tasks" 3.To filter by L.text where it contains "urgent" or "Email" or "design" 4.To display the result as a table [without the desired structure]
collapse: close
icon:
color:
```dataview
TABLE WITHOUT ID
choice(L.task, "- [" + L.status + "] " + L.text, "- " + L.text) AS "milestones_or_tasks",
L.task AS "task",
L.status AS "status",
L.text AS "text",
F_subpath AS "F_subpath",
F_type AS "F_type",
file.link AS "File"
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data"
FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type
WHERE L.task and !L.completed
WHERE contains(F_subpath, "tasks") AND F_type = "header"
WHERE contains(L.text, "urgent") OR
contains(L.text, "Email") OR
contains(L.text, "design")
SORT file.name ASC
```
Screenshots(DQL03)
DQL05_flatten_fLists_and_display_list_items_and_task_items_under_the_heading
- To gather list items where the heading contains “milestones”
- To gather task items where the heading contains “tasks”
Summary
Main DQL
Code Name | Data type | Group By | Purposes | Remark |
---|---|---|---|---|
DQL05_flatten_fLists _and_display_list_items _and_task_items _under_the_heading |
file.lists | no | 1.To flatten file.lists 2.To gather list items where the heading contains “milestones” 3.To gather task items where the heading contains “tasks” 4.list items: To filter by L.text where it contains “feature_A” or “feature_B” or “feature_E” 5.task items: To filter by L.text where it contains “urgent” or “Email” or “design” 6.To display the result as a table [without the desired structure] |
Code DQL05_flatten_fLists_and_display_list_items_and_task_items_under_the_heading
- To gather list items where the heading contains “milestones”
- To gather task items where the heading contains “tasks”
Summary_code
title: DQL05_flatten_fLists_and_display_list_items_and_task_items_under_the_heading =>1.To flatten file.lists 2.To gather list items where the heading contains "milestones" 3.To gather task items where the heading contains "tasks" 4.list items: To filter by L.text where it contains "feature_A" or "feature_B" or "feature_E" 5.task items: To filter by L.text where it contains "urgent" or "Email" or "design" 6.To display the result as a table [without the desired structure]
collapse: close
icon:
color:
```dataview
TABLE WITHOUT ID
choice(L.task, "- [" + L.status + "] " + L.text, "- " + L.text) AS "milestones_or_tasks",
L.task AS "task",
L.status AS "status",
L.text AS "text",
F_subpath AS "F_subpath",
F_type AS "F_type",
file.link AS "File"
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data"
FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type
WHERE !L.task OR (L.task and !L.completed)
WHERE (contains(F_subpath, "milestones") AND F_type = "header")
OR (contains(F_subpath, "tasks") AND F_type = "header")
WHERE (
!L.task AND
(
contains(L.text, "feature_A") OR
contains(L.text, "feature_B") OR
contains(L.text, "feature_E")
)
)
OR
(
L.task AND
(
contains(L.text, "urgent") OR
contains(L.text, "Email") OR
contains(L.text, "design")
)
)
SORT file.name ASC
```
Screenshots(DQL05)
DQL07_flatten_fLists_groupBy_fLink_and_display_list_items_and_task_items_under_the_heading
- To gather list items where the heading contains “milestones”
- To gather task items where the heading contains “tasks”
- To group by file.link and
let G_file_link = rows.file.link;
- To sort by G_file_link in descending order
Summary
Main DQL
Code Name | Data type | Group By | Purposes | Remark |
---|---|---|---|---|
DQL07_flatten_fLists _groupBy_fLink _and_display_list_items _and_task_items _under_the_heading |
file.lists | yes | 1.To flatten file.lists 2.To gather list items where the heading contains “milestones” 3.To gather task items where the heading contains “tasks” 4.list items: To filter by L.text where it contains “feature_A” or “feature_B” or “feature_E” 5.task items: To filter by L.text where it contains “urgent” or “Email” or “design” 6.To group by file.link and let G_file_link = rows.file.link; 7.To sort by G_file_link in descending order 8.To display the result as a table [without the desired structure] |
Code DQL07_flatten_fLists_groupBy_fLink_and_display_list_items_and_task_items_under_the_heading
- To gather list items where the heading contains “milestones”
- To gather task items where the heading contains “tasks”
- To group by file.link and
let G_file_link = rows.file.link;
- To sort by G_file_link in descending order
Summary_code
title: DQL07_flatten_fLists_groupBy_fLink_and_display_list_items_and_task_items_under_the_heading =>1.To flatten file.lists 2.To gather list items where the heading contains "milestones" 3.To gather task items where the heading contains "tasks" 4.list items: To filter by L.text where it contains "feature_A" or "feature_B" or "feature_E" 5.task items: To filter by L.text where it contains "urgent" or "Email" or "design" 6.To group by file.link and `let G_file_link = rows.file.link;` 7.To sort by G_file_link in descending order 8.To display the result as a table [without the desired structure]
collapse: close
icon:
color:
```dataview
TABLE WITHOUT ID
map(rows.L, (L) => choice(L.task, "- [" + L.status + "] " + L.text, L.text)) AS "milestones_or_tasks",
rows.L.task AS "task",
rows.L.status AS "status",
rows.F_subpath AS "GF_subpath",
rows.F_type AS "GF_type",
length(rows) AS "QTY",
G_file_link AS "File"
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data"
FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type
WHERE !L.task OR (L.task and !L.completed)
WHERE (contains(F_subpath, "milestones") AND F_type = "header")
OR (contains(F_subpath, "tasks") AND F_type = "header")
WHERE (
!L.task AND
(
contains(L.text, "feature_A") OR
contains(L.text, "feature_B") OR
contains(L.text, "feature_E")
)
)
OR
(
L.task AND
(
contains(L.text, "urgent") OR
contains(L.text, "Email") OR
contains(L.text, "design")
)
)
SORT file.name ASC
GROUP BY file.link AS G_file_link
SORT G_file_link DESC
```
Screenshots(DQL07)
DQL10_flatten_fLists_and_display_uncompleted_tasks
Summary
Main DQL
Code Name | Data type | Group By | Purposes | Remark |
---|---|---|---|---|
DQL10_flatten_fLists _and_display_uncompleted_tasks |
file.lists | no | 1.To filter by task items 2.To filter by uncompleted task items 3.To filter by F_prefix_text where it starts with “T01” or “T02” or “T03” 4.To sort by F_prefix_text in ascending order 5.To display the result as a table [without the desired structure] |
Code DQL10_flatten_fLists_and_display_uncompleted_tasks
Summary_code
title: DQL10_flatten_fLists_and_display_uncompleted_tasks =>1.To filter by task items 2.To filter by uncompleted task items 3.To filter by F_prefix_text where it starts with "T01" or "T02" or "T03" 4.To sort by F_prefix_text in ascending order 5.To display the result as a table [without the desired structure]
collapse: close
icon:
color:
```dataview
TABLE WITHOUT ID
choice(L.task, "- [" + L.status + "] " + L.text, "- " + L.text) AS "milestones_or_tasks",
F_prefix_text AS "F_prefix_text",
L.status AS "status",
L.text AS "text",
F_subpath AS "F_subpath",
F_type AS "F_type"
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data"
FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type
FLATTEN choice(contains(L.text, "✉️") OR (L.status = ">"),
"T01" + L.text,
choice(contains(L.text, "❗") OR (L.status = "!"),
"T02" + L.text,
choice(contains(L.text, "📐"), "T03" + L.text, "T99" + L.text))
) AS F_prefix_text
WHERE L.task and !L.completed
WHERE startswith(F_prefix_text, "T01") OR
startswith(F_prefix_text, "T02") OR
startswith(F_prefix_text, "T03")
SORT F_prefix_text ASC
```
Screenshots(DQL10)
DQL20_use_fTasks_and_display_uncompleted_tasks
Summary
Main DQL
Code Name | Data type | Group By | Purposes | Remark |
---|---|---|---|---|
DQL20_use_fTasks _and_display_uncompleted_tasks |
flattened file.tasks | no | 1.To filter by a task 2.To filter by a uncompleted task 3.To filter by F_prefix_text where it starts with “T01” or “T02” or “T03” 4.To sort by F_prefix_text in ascending order 5.To display the result as a taskList [with the desired structure] |
Notes
Summary
Q: What does the following DQL statement mean?
WHERE !completed
FLATTEN choice(contains(text, "✉️") OR (status = ">"),
"T01" + text,
choice(contains(text, "❗") OR (status = "!"),
"T02" + text,
choice(contains(text, "📐"), "T03" + text, "T99" + text))
) AS F_prefix_text
SORT F_prefix_text ASC
A1: In English
For each uncompleted task :
case_T01: If contains(text, “”) OR (status = “>”), let F_prefix_text = “T01” + text;
case_T02: If contains(text, “”) OR (status = “!”), let F_prefix_text = “T02” + text;
case_T03: If contains(text, “”), let F_prefix_text = “T03” + text;
case_T99: Otherwise, let F_prefix_text = “T99” + text;
Sort it by the F_prefix_text
in ascending order
After sorting it by the F_prefix_text
in ascending order :
- Each task of case_T01 is in front of each task of case_T02 because “T01” is in front of “T02”.
- “T01” is the prefix of each
F_prefix_text
of case_T01 - “T02” is the prefix of each
F_prefix_text
of case_T02
- “T01” is the prefix of each
- Each task of case_T02 is in front of each task of case_T03 because “T02” is in front of “T03”.
- “T02” is the prefix of each
F_prefix_text
of case_T02 - “T03” is the prefix of each
F_prefix_text
of case_T03
- “T02” is the prefix of each
A2: Screenshots(DQL20_notes)
case_T01
case_T02
case_T03
case_T01 or case_T02 or case_T03
Sort it by the F_prefix_text
in ascending order
Code DQL20_use_fTasks_and_display_uncompleted_tasks
Summary_code
title: DQL20_use_fTasks_and_display_uncompleted_tasks =>1.To filter by a task 2.To filter by a uncompleted task 3.To filter by F_prefix_text where it starts with "T01" or "T02" or "T03" 4.To sort by F_prefix_text in ascending order 5.To display the result as a taskList [with the desired structure]
collapse: close
icon:
color:
```dataview
TASK
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data"
WHERE !completed
FLATTEN choice(contains(text, "✉️") OR (status = ">"),
"T01" + text,
choice(contains(text, "❗") OR (status = "!"),
"T02" + text,
choice(contains(text, "📐"), "T03" + text, "T99" + text))
) AS F_prefix_text
WHERE startswith(F_prefix_text, "T01") OR
startswith(F_prefix_text, "T02") OR
startswith(F_prefix_text, "T03")
SORT F_prefix_text ASC
```
Screenshots(DQL20)
Related resources
Summary
- The file.lists by example - Chapter 2 : using DVJS to gather list items or task items under the specific heading and group by a column (and group by another column)
- The file.lists by example - Chapter 3: using DQL to gather list items or task items under the specific heading (and filter by a field) (and sum up a field) (and display each DVIF)
- The file.lists by example - Chapter 4: using DQL(or DVJS) to gather list items or task items under the specific heading (and filter by L.text)(and filter by L.task or !L.task)(and filter by L.tags or L.outlinks) without(or with) the desired structure