Open and write a file.csv

This forum is dedicated to everything about MemBrain Scripting. All Questions or other contributions with respect to scripting should be placed here.
Especially, if you have an interesting script that you might want to share with other MemBrain users, please post it within a new topic in this forum. Try to choose a title for your topic that allows other users to quickly identify the basic purpose of your script.
Post Reply
Posts: 2
Joined: Tue 22. May 2012, 16:48

Open and write a file.csv

Post by Alessandro » Tue 12. Jun 2012, 10:56

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.


User avatar
Site Admin
Posts: 438
Joined: Sun 16. Nov 2008, 18:21

Re: Open and write a file.csv

Post by Admin » Wed 13. Jun 2012, 00:04

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?

(1.55 KiB) Downloaded 552 times
(1.7 KiB) Downloaded 560 times
Thomas Jetter

Posts: 2
Joined: Tue 22. May 2012, 16:48

Re: Open and write a file.csv

Post by Alessandro » Fri 15. Jun 2012, 10:50

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.



Post Reply