# Summarize Daily Notes Using Dataview

**URL:** <https://forum.obsidian.md/t/summarize-daily-notes-using-dataview/18049>\
**Category:** Workflows & Templates\
**Tags:** dataview, daily-note\
**Created:** [May 12, 2021, 4:12am UTC](https://forum.obsidian.md/t/summarize-daily-notes-using-dataview/18049 "2021-05-12T04:12:41Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![AlanG](https://forum.obsidian.md/user_avatar/forum.obsidian.md/alang/32/55225_2.png) [@AlanG](https://forum.obsidian.md/u/AlanG)\
**Post date:** [August 29, 2022, 5:10am UTC](https://forum.obsidian.md/t/summarize-daily-notes-using-dataview/18049/9 "2022-08-29T05:10:36Z")

</div>

> [@SiliasOS](#):
>
> Now I’m wondering, if I could use dataview, to just summerize all the content, I wrote underneath the “what happend today?”-heading.

You can extract the full “What happened today?” section via regex.

For best performance you’ll want to change the Dataview query `dv.pages()` to limit it to your daily notes only. If you use the tag “#daily”, that would be `dv.pages('#daily')`

````
```dataviewjs
const header = '## What happened today\\?'

// You can update this to filter as you like - filtering for just your daily notes would be good
const pages = dv.pages()

// This regex will return text from the Summary header, until it reaches
// the next header, a horizontal line, or the end of the file
const regex = new RegExp(`\n${header}\r?\n(.*?)(\n#+ |\n---|$)`, 's')

for (const page of pages) {
    const file = app.vault.getAbstractFileByPath(page.file.path)
    // Read the file contents
    const contents = await app.vault.read(file)
    // Extract the summary via regex
    const summary = contents.match(regex)
    if (summary) {
        // Output the header and summary
        dv.header(2, file.basename)
        dv.paragraph(summary[1].trim())
    }
}
```

````

---

_[View the full topic](https://forum.obsidian.md/t/summarize-daily-notes-using-dataview/18049)._
