# Watch and load CSVs

This example uses a file watcher to scan for CSV's and parse them into a **`DataTable`**. It prints the info about it.

```csharp
PerigeeApplication.ApplicationNoInit("Watcher Demo", (c) =>
{

    c.AddDirectoryWatch("CSV", "C:\\temp\\Watch", "*.csv", SearchOption.AllDirectories, (ct, l, path) => {

        //Read the CSV
        var CSVData = CSVReader.ToDataTable(path, out var rRes);

        //Reprt on it
        l.LogInformation("Read CSV {file}[{encoding}]. Columns/Rows: {col}/{row}; Delimiter: {delChar}; Jagged? {jagged}", 
            Path.GetFileName(path), rRes.FileEncoding.EncodingName, rRes.ColumnCount, 
            CSVData.Rows.Count, rRes.FinalDelimiter, rRes.RowShifts.Count > 0 ? "YES" : "NO");

        //You'll notice the file gets moved to the _Failed Folder (Due to DirectoryWatchFailurePolicy supplied below)
        //  Watcher expects the file to be removed after it's processed to prevent infinite loops


    }, policy: ThreadRegistry.DirectoryWatchFailurePolicy.MoveToFailedFolder);

});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.perigee.software/examples-and-demos/watch-and-load-csvs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
