I'm having a little trouble here. I want to use data for my model from two files: one with extension .txt and other one with extension .csv. Then I want to have access to that especific data to process it as parameters. Do I have to use a function? What would be your take on this topic? Thank you!
PD: I'm using OpenModelica.
I've tried the ExternData library but I think I don´t get it quite right.
fileName=Modelica.Utilities.Files.loadResource("modelica:/Files/Examples/CSVReader/Data.csv"),
I think the ExternData
library is a pretty good choice. It supports both file-types and should do what you want - although the question is a bit fuzzy in that regard.
Did you take a look at ExternData.Examples.CSVTest
? That should explain how the library is used. Basically, it is a two-step process:
dataSource
class to specify the path to the file as well as the file-type.dataSource
, e.g. dataSource.getRealArray2D(3, 2)
with the integers defining the size of the matrix that is read.For more details: https://ecp.ep.liu.se/index.php/modelica/article/view/189.