Comments (17)
For anyone else that ends up here, I used the recommendation above to build a dataviewjs block that brings in the list of quotes of my files tagged w/ people
(which use a template that adds a quotes section using the comment delimiters I refer to in the snippet:
let quotesPromises = dv.pages("#people").map(async (p) => {
const link = p.file.link;
return await dv.io.load(p.file.link).then((contents) => {
const indexOfQuotes = contents.indexOf("<!-- quotes -->");
if (indexOfQuotes > 0) {
const quoteStart = contents
.substr(indexOfQuotes + 16)
const quotes = quoteStart.substr(0, quoteStart.indexOf("<!-- end quotes -->")).trim();
if (quotes === "") {
return [];
} else {
return quotes.split(">").map(q => q.trim()).filter((q) => q !== "").map((quote) => [p.file.link, quote]);
}
} else {
return []
}
});
});
let quotes = (await Promise.all(quotesPromises)).flat().filter((q) => q.length > 0);
dv.table(["Author", "Quote"], quotes);
Which yields something like this:
from obsidian-dataview.
Interesting idea. I am planning on adding a "embed query", where you can query for sections / blocks / whatnot and they will render similarly to if you had done a bunch of manual ![[]] embed statements, which will get part of what you want.
Editing in place sounds cool, though would be difficult (dataview generally works where you write the query in edit mode, and view the result dynamically in preview mode). It might be possible via a custom view (i.e., a "query" view where you type in a query at the top and you can view results at the bottom), though that would be further in the future.
from obsidian-dataview.
Editing in place sounds cool, though would be difficult (dataview generally works where you write the query in edit mode, and view the result dynamically in preview mode). It might be possible via a custom view (i.e., a "query" view where you type in a query at the top and you can view results at the bottom), though that would be further in the future.
I didn't mean that; I meant editing the contents of the sections or blocks, with the dataview being a window onto the underlying files, so that it'd be like a spreadsheet view of parts of my notes. But being able to click on the embeds to open the relevant note sections in another pane would be a good substitute.
from obsidian-dataview.
Yeah, that's not really what I had in mind, which was more to either 1) query list items from all headings with a certain name across all files containing that heading, or 2) generate a TABLE query and put the contents found under a heading (list or otherwise) as one of the columns. For example, if I had a bunch of notes with headers (or block IDs) A, B, and C, then being able to generate a table that showed a row for each note with columns A, B, and C containing the rendered contents under those headings (or block IDs).
In other words, the goal wasn't to query all list items in a note and then filter or group them by section, but to extract specific blocks or sections from queried notes and render them in a dataview table, with the entire list (or other block/section contents) embedded in a column, as though the heading were a dataview field.
from obsidian-dataview.
It would be best if sections were just inline fields whose values could be a list or markdown. So that would be more like they just exist as top level properties (e.g. file["some section"]
), especially if they were something that the table rendering was smart enough to turn back into a list in the cell (and the query language allows you to name fields that way, I guess).
Anyway, the main goal is that it should be easy to write a non-JS table query that puts the contents of a named file sections into different table cell. It'd be ideal if that was a single step like file["some section name"]
, where the section name uses kebab-casing internally to match the heading. (Both of your examples are using lists rather than maps, which means you have to write a loop for every such column you want to create, vs file{"section A"], file["section B"]
to create two columns in a table query.
from obsidian-dataview.
@blacksmithgu quick question on this:
Interesting idea. I am planning on adding a "embed query", where you can query for sections / blocks / whatnot and they will render similarly to if you had done a bunch of manual ![[]] embed statements, which will get part of what you want.
I've got a bunch of notes structured like this, with the file name being an account name:
##### 2020-04-29
- This is a note.
- This is another note.
I generate reports from Obsidian by using a manually structured table. One of the cells includes a link to the most recent section, e.g. ![[That Account#2020-04-29]]
, which embeds the notes from that section directly into the report. Would the feature you mentioned above replicate that behavior? That's currently the only item holding me back from converting everything over to Dataview. I just wanted to make sure before opening a FR: no reason if it's already planned.
Thanks and keep up the great work!
from obsidian-dataview.
Is there any way at all to access the contents of a file using data view? I don't even mind having to write a regex or something to do it, but it would be awesome if possible.
from obsidian-dataview.
You can use await dv.io.load(path|link)
using DataviewJS, though it is not supported in Dataview currently.
from obsidian-dataview.
ohhh, nice let me try that out :) I've ended up using dataviewjs instead of dataview in most places since I know js anyway.
from obsidian-dataview.
One other thing that would be amazing is if there was some way to use dv.io.load(link)
and get a specific heading. I'm trying to iterate over files and get a specific heading out of each of them, so I don't see a way currently to go from file link to file + heading link.
from obsidian-dataview.
This prevents me from needing to regex a markdown heading.
from obsidian-dataview.
You can now query list items under specific section headings. Does that fulfill the original ask?
from obsidian-dataview.
You can now query list items under specific section headings.
How? I just checked the DQL reference and didn't see anything for that. The only reference to sections I found was in relation to TASK
queries, which doesn't handle plain list items (or text)?
from obsidian-dataview.
Can be found under the file.lists
object and you can inspect list items to see that they now have a section attribute.
from obsidian-dataview.
@pjeby From an API perspective, would you prefer the section data to be:
- directly inline in the results, like:
{
file: {
sections: [
{ name: ..., }
]
}
}
- or as links which are de-referenced into section objects, such as:
{
file: {
sections: [
[[File#Section 1]],
...
]
}
}
from obsidian-dataview.
I would be very interested in having access to sections as well. For my use-case having a list of sections with their name and content in file.sections
would be sufficient, similar to the first suggestion mentioned here: #29 (comment)
from obsidian-dataview.
Does this possible now?
from obsidian-dataview.
Related Issues (20)
- date function fails for null values when format is given. HOT 3
- export of a table to Excel, CSV, JSON etc. HOT 7
- Tasks: Dataview shows empty tasks HOT 2
- Dataview shows all tasks on a page, rather than only the ones specified in the query HOT 1
- Tasks starting with a number followed by a period are not recognized as tasks
- Dataview path to folders and files on ios HOT 2
- dv.view("folder path") doesn't attach CSS to the top
- Explain how to query using a list property that contains internal links
- Bug: replace doesn't replaceAll
- Multiple dataviews in one place HOT 1
- file.ext to show .canvas, .pdf etc.
- Embedding wide tables makes headers overflow HOT 2
- api.version.compare('>=', '0.5.31') no longer works HOT 7
- Bug report: Cross-Event Time Display Error in Preview Mode HOT 1
- file view dependent context HOT 2
- Inline field with list only displays last entry in Live Preview mode HOT 4
- Default search queries HOT 1
- Bug report - Cursor doesn't get placed correctly
- Bug report - inlinefield rendered inside a inline code and it make a mess HOT 1
- Dataview causes screen flickering. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obsidian-dataview.