> For the complete documentation index, see [llms.txt](https://docs.graph.build/EGeX4aTAJLlpg9Hh8kfl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.graph.build/EGeX4aTAJLlpg9Hh8kfl/semi-structured-transformer/triggering-the-transformer-ingesting-data.md). Agents can also search and read this documentation through its [MCP server](https://docs.graph.build/EGeX4aTAJLlpg9Hh8kfl/~gitbook/mcp).

# Triggering the Transformer / Ingesting Data

The SS Transformer supports a number of ways to ingest your data files. While all five supported file types, CSV, XML, JSON, XLSX, and ODS, are ingested in the same way, there may be some additional parameters you wish to set for CSV and XML as detailed below.

### Executing From The Studio

The SS transformer can be executed directly from the Studio. Instructions on how to do this are found in the getting started tutorial [here](https://docs.graph.build/EGeX4aTAJLlpg9Hh8kfl/getting-started-tutorial/rdf-ontologies-and-models/semi-structured-model-design/executing-a-full-transformation.md). Slightly different configuration options are required when executing on a LPG model which can be found [here](https://docs.graph.build/EGeX4aTAJLlpg9Hh8kfl/getting-started-tutorial/lpg-schemas-and-models/semi-structured-model-design/executing-a-full-transformation.md).

It can be confusing when running on a local machine to know the path to give to your input file. Instructions on the path to use can be found [here](https://docs.graph.build/EGeX4aTAJLlpg9Hh8kfl/semi-structured-transformer/triggering-the-transformer-ingesting-data/input-file-url-when-running-on-a-local-machine.md).

### RESTful API Endpoint

Outside of using the Graph.Build Studio, the easiest way to ingest a file into the SS Transformer is to use the built-in APIs. Using the `process` POST endpoint, you can specify the URL of a file to ingest along with the `logicalSource` correlating to your mapping, and in return you will be provided with the URL(s) of the generated Graph data file(s).

The request is a `POST` to `http://<transformer-ip>:<transformer-port>/process` with a JSON body (`Content-Type: application/json`) rather than URL query parameters. A minimal request body looks like this:

```json
{
    "inputFileURL": "file:///var/local/input-data.csv",
    "logicalSource": "sample.csv"
}
```

The response is a success report in the form of a JSON object.

For ingestions where you wish to transform an input source file with a specific mapping file, or mapping files within a specific directory, you can also include a `mappingURL` field pointing to your mapping file or mapping directory:

```json
{
    "inputFileURL": "file:///var/local/input-data.csv",
    "logicalSource": "sample.csv",
    "mappingURL": "file:///var/local/my-mapping.ttl"
}
```

Otherwise, omitting `mappingURL` will cause the Transformer to run normally, importing all mapping files within the mapping directory URL specified in the configuration.

In addition, you may wish to ingest multiple input source files in instances where there are joins in your mapping, creating links between your data. This is done by supplying `inputFileURL` and `logicalSource` as arrays, with each input file paired with its correlating logical source. For example, to ingest two files:

```json
{
    "inputFileURL": [
        "file:///var/local/employees-123.csv",
        "file:///var/local/jobRoles-123.xml"
    ],
    "logicalSource": ["employees.csv","jobRoles.xml"]
}
```

This can also be combined with a specific `mappingURL` in the same way as the example above.

### Kafka <a href="#kafka" id="kafka"></a>

The second, and the more versatile and scalable ingestion method, is to use a message queue such as Apache Kafka. To set up a Kafka Cluster, follow the instructions [here](https://docs.graph.build/EGeX4aTAJLlpg9Hh8kfl/stack-run-configurations/docker/full-stack-with-rdfox-connection.md), but in short, to ingest files into the SS Transformer you must set up a Producer and connect to your cluster by setting the `KAFKA_BROKERS` variable to the same as your Kafka endpoint, and ensure the `TRANSFORMER_RUN_STANDALONE` configuration is set to `false`. The topic name that this Producer publishes to must be the same name that you specified in the `KAFKA_TOPIC_NAME_SOURCE` config option (defaults to “source\_urls”). Once set up, each message sent from the Producer must be a JSON object containing the URL(s) of the input file(s), the correlating logical sources, as well as optionally a mapping file or mapping directory if you wish to give a specific mapping per process.

The JSON object must be structured as follows:

```json
{
  "input": [
    {"inputFileURL": "", "logicalSource": ""},
    {"inputFileURL": "", "logicalSource": ""}
  ],
  "mappingURL": ""
}
```

### S3 Lambda <a href="#s3-lambda" id="s3-lambda"></a>

If you wish to use Kafka, and you are also using S3 to store your source data, we have developed an [AWS Lambda](https://aws.amazon.com/lambda/) to aid with the ingestion of data into your SS Transformer. The Lambda is designed to monitor a specific Bucket in S3, and when a file arrives or is modified in a specific directory, a message is written to a specified Kafka Topic containing the URL of the new/modified file. Subsequently, this will then be ingested by the Transformer. If you wish to use this Lambda, please contact us for more information.

### CSV Splitting and Validation <a href="#csv-splitting-and-validation" id="csv-splitting-and-validation"></a>

While ingesting CSV files is the same as with XML and JSON, there are a couple of points to note. A very large CSV file with a large number of rows will be split into chunks and processed separately, by default every 100,000 lines. This allows for better performance and continuous output of RDF files. When processed using Kafka, messages are continuously pushed to the Success Queue; however when using the Process endpoint, the response will only be returned once the entire file transformation has been completed. This file chunking size can be overridden with the configuration option `MAX_CSV_ROWS`, or conversely turned off by setting this to 0; however this is not recommended unless your machine / instance has a significant amount of RAM.

In addition, CSV files are validated by default before being processed, and any erroneous lines will be removed and not transformed. This has a negligible effect on the performance, however can be turned off by setting `VALIDATE_CSV` to false. Please note that multiline CSV records are not supported with this validation functionality, so please turn this feature off if multiline is present in your dataset.

### XML Parsing <a href="#xml-parsing" id="xml-parsing"></a>

Ingesting XML files is also the same process as with CSV and JSON files; however there are currently two different parsing methodologies that can be used. This is explained more when you create your model using our guide, but SAXPath can be used for faster transformation speed, and XPath can be utilised when complex iterators are used including accessing parent nodes.
