system.mes.operation.importFromCsv
Description
Imports Operations from a CSV file provided as a string or as raw bytes. The service layer will parse the CSV content and create or update operation entities based on the 'name' and 'location' columns.
Recommended to export at least one pre-existing operation to CSV using the Export Operations functionality to ensure the correct format of the CSV file.
Syntax
system.mes.operation.importFromCsv(importBytes)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
importBytes | PyArray | False | The CSV content as raw bytes. |
Returns
The number of operations 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.
Bytes
def runAction(self, event):
csvBytes = event.file.getBytes()
system.mes.operation.importFromCsv(csvBytes)
String
def runAction(self, event):
csvString = event.file.getString()
system.mes.operation.importFromCsv(csvString)