# core.script_api:init_datafile()


Initialize the datafile for the matrix_script measurement.


Usage

``` python
core.script_api:init_datafile(
    filename,
    comment=None,
    append=False,
    print_header=True,
    ntot=None,
    reset_meta_data=True,
    reset_date=True,
)
```


By default a new datafile will be generated whose name is generated in a way that no existing datafile can be overwritten.


## Parameters


`filename: str`  
Name of the datafile to be used.

`comment: str = None`  
Comment to be saved in the file header.

`append: bool = ``False`  
Flag to tell if an existing datafile should be used. If append is False a new datafile with a non-conflicting name will be generated by appending "\_" to the filename.

`print_header: bool = ``True`  
Flag to decide if the header information with column names and units should be printed.

`ntot: int = None`  
Deprecated manual total number of expected datapoints. When omitted, matrix-script infers the total from statically analyzable source.

`reset_meta_data: bool = ``True`  
If True, reset metadata to the values captured at script start before creating a new file.

`reset_date: bool = ``True`  
If True, refresh `meta_data["date"]` to the current time before creating a new file.
