# Split Document

### How It Works

```bash
$ npm run start -- split-document -h
Usage: robosaur split-document [options] <configFile>

Split document into multiple projects

Options:
  -h, --help  display help for command
```

* Robosaur can split a file based on the configuration. The split mechanism could state how many lines per file (`linesPerFile`) and how many files per folder (`filesPerFolder`).
* Specifically for this command, `datasaur` and `projectState` attributes won't be needed on the configuration since there is no API call, that's why the explanation below only consist of `splitDocument` attribute.

### Configuration

```json
{
  "splitDocument": {
    "path": "<path-to-a-file-that-will-be-split>",
    "header": true,
    "linesPerFile": 100,
    "filesPerFolder": 10,
    "resultFolder": "<path-to-all-split-files-result>"
  }
}
```

#### Path

Specify the file location that will be split. Currently, Robosaur can only process a file that is located on your device.

#### Result Folder

The result of split files will be placed to this folder. Currently, Robosaur can only put the result files on a folder that is located on your device. The result will be compatible with project creation input. The result folder will be created if it doesn't exist and **will be emptied if it already exists**.

#### Header

Whether the CSV file has a header or not.

#### Files Per Folder <a href="#execution-modes" id="execution-modes"></a>

The reason for this attribute is to make the split result compatible with [project creation command](https://docs.datasaur.ai/integrations/robosaur/commands/create-projects) as the input so that you can combine these two commands. Each folder inside the result will be treated as a project and each files inside every folder will be treated as the documents.

#### Lines Per File <a href="#execution-modes" id="execution-modes"></a>

The number of lines each file will have before Robosaur creates another split file.
