system.mes.material.importFromCsv
Description
Imports Materials from a CSV file provided as raw bytes. The service layer parses the CSV content and creates or updates material entities.
Recommended to export at least one pre-existing material to CSV using the Export Materials functionality to ensure the correct format of the CSV file.
Syntax
system.mes.material.importFromCsv(importBytes)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
importBytes | PyArray | False | The CSV content as raw bytes. |
Returns
An ApiResponse object where data is the number of materials successfully imported or updated.
Code Examples
Here is an example of how to use the importFromCsv method in the context of a Perspective File Upload Component
onFileReceived event handler. Reference Perspective - File Upload Scripting
for more information on the onFileReceived event handler.
def runAction(self, event):
csvBytes = event.file.getBytes()
system.mes.material.importFromCsv(csvBytes)