Page 1 of 1

Open and write a file.csv

Posted: Tue 12. Jun 2012, 10:56
by Alessandro
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

Re: Open and write a file.csv

Posted: Wed 13. Jun 2012, 00:04
by Admin
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

Re: Open and write a file.csv

Posted: Fri 15. Jun 2012, 10:50
by Alessandro
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