# csv_utils

The `csv_utils` module provides a set of procedures for managing CSV files within Memgraph.
It allows users to create and delete CSV files directly from the database environment.

| Trait               | Value               |
| ------------------- | ------------------- |
| **Module type**     | util                |
| **Implementation**  | C++                 |
| **Parallelism**     | sequential          |

## Procedures

### `create_csv_file()`

This procedure creates a new CSV file at the specified path with the given content.
If the file already exists, the `is_append` flag determines whether the content should be appended to the file or overwritten.

#### Input:

- `filepath: string` ➡ The path where the CSV file will be created.
- `content: string` ➡ The content to be written into the CSV file.
- `is_append: bool (default = false)` ➡ If `true`, the content is appended to the existing file; otherwise, the file is overwritten.

#### Output:

- `filepath: string` ➡ The path of the created CSV file.

#### Usage:

To create a new CSV file:

```cypher
CALL csv_utils.create_csv_file("/tmp/data.csv", "id,name\n1,John", false) YIELD filepath;
```

To append data to an existing CSV file:

```cypher
CALL csv_utils.create_csv_file("/tmp/data.csv", "2,Jane", true) YIELD filepath;
```

### `delete_csv_file()`

This procedure deletes the specified CSV file.

#### Input:

- `filepath: string` ➡ The path of the CSV file to be deleted.

#### Output:

None.

#### Usage:

To delete an existing CSV file:

```cypher
CALL csv_utils.delete_csv_file("/tmp/data.csv");
```
