I'm trying to write a script that crates a file Inputs.csv. In such a file should be then written some inputs values (say IN1, IN2, IN3) asked via screan to the operator. Eventually, when the Inputs.csv is ready, it should be read as Input file from Membrain.
I have problems in creating this new file, asking via screan the values of the inputs (IN1, IN2,IN3) and writing on the created file the inserted data. I tryied with a C sintax, but i get errors. Should I include some module from the library.
I hope sombody can help me.
Thanks in advance.
Alessandro
Open and write a file.csv
Re: Open and write a file.csv
Hi Alessandro,
I wrote a small example script and attached it to this post which shows how to do the actions that I think you want to realize.
One additional comment on creating CSV files with MemBrain scripting: Basically the approach is not to create a CSV file through scripting and then load it into MemBrain. It's actually the other way round: The script creates the corresponding data entity (a MemBrain 'Lesson') and then exports this Lesson to CSV. It would certainly also be possible to directly write text strings to a file and thus building a CSV. However, the other way round is much simpler: Just use the Lesson CSV export functions of MemBrain as implemented in the attached script.
The CSV file can certainly be loaded again from file through scripting in case you need to at a later point in time.
Please copy both the script and the example net into one folder and then run the script from MemBrain.
Does this help for the first?
Regards
I wrote a small example script and attached it to this post which shows how to do the actions that I think you want to realize.
One additional comment on creating CSV files with MemBrain scripting: Basically the approach is not to create a CSV file through scripting and then load it into MemBrain. It's actually the other way round: The script creates the corresponding data entity (a MemBrain 'Lesson') and then exports this Lesson to CSV. It would certainly also be possible to directly write text strings to a file and thus building a CSV. However, the other way round is much simpler: Just use the Lesson CSV export functions of MemBrain as implemented in the attached script.
The CSV file can certainly be loaded again from file through scripting in case you need to at a later point in time.
Please copy both the script and the example net into one folder and then run the script from MemBrain.
Does this help for the first?
Regards
- Attachments
-
- TestNet.mbn
- ExampleNet
- (1.55 KiB) Downloaded 1336 times
-
- CreateCSV.as
- ExampleScript
- (1.7 KiB) Downloaded 1326 times
Thomas Jetter
-
- Posts: 2
- Joined: Tue 22. May 2012, 16:48
Re: Open and write a file.csv
Hello Thomas,
Thank you very much for the example. It has been very usefull.
I also got the right way to approach the script. It's better to write the script thinking
from the Membain point of view than to force Membrain to compile and execute a
script written as it were a C Program.
Regards.
Alessandro
Thank you very much for the example. It has been very usefull.
I also got the right way to approach the script. It's better to write the script thinking
from the Membain point of view than to force Membrain to compile and execute a
script written as it were a C Program.
Regards.
Alessandro