How to save and read multidimensional array
How to save and read multidimensional array
27 Oct 2019, 18:57
Hi, How to save and read from file multidimensional array? I need this to not loose data (array) when restarting robot. Is there any other way to not loose data when rebooting?
Replies
radoslawkupisek
30 Oct 2019, 17:39
Ok, still not sure how to use it..
When I copy the egsample then I've got" Error : No algo source file was found in "ReadWriteCsv.csproj"".
When I just use some of this code at the end when the program stops as"
protected override void OnStop()
{
using (var streamWriter = File.CreateText("123.csv"))
{
var writer = new CsvWriter(streamWriter);
writer.WriteRecords(Table);
}
}
Then I ve got Error CS0246: saying that there is no CsvWriter. despite the fact that I have on the beginning of my robot
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using System.IO;
using System.Text;
using System.Collections.Generic;
How it should be done to be able to save this file?
@radoslawkupisek
firemyst
31 Oct 2019, 02:47
It seems to me your issue is referencing the dll class file.
I don't believe CsvWriter is standard issue C# .Net library.
I'm guessing you want CsvHelper.CsvWriter class? If so, you need to add a reference to your project for the CsvHelper dll assembly.
The only way you can do that is if you've downloaded and installed the CsvHelper dll file somewhere on your computer.
Do a google search, and you'll see you can download it here: https://joshclose.github.io/CsvHelper/
@firemyst
PanagiotisCharalampous
31 Oct 2019, 08:12
Hi radoslawkupisek,
The refenence was provided as a guide on how to read and write to and from csv files. From there and on you will need to adjust it to your code. You cannot just copy and paste things and expect them to work. If it is hard for you to implement it, you can always contact a Consultant or post a Job.
Best Regards,
Panagiotis
@PanagiotisCharalampous
radoslawkupisek
04 Nov 2019, 19:15
OK, what can we do if there is right code to write and read but we get "04/11/2019 20: 10: 21.934 | RK RENKO v9, EURUSD, Re10 | Crashed in OnStop with SecurityException: Permission request of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089' failed."?
@radoslawkupisek
PanagiotisCharalampous
29 Oct 2019, 08:33
Hi radoslawkupisek,
You can consider saving your data in a csv file and read them again on cBot start up. There are a lot of useful resources on the internet on how to do that like this one.
Best Regards,
Panagiotis
@PanagiotisCharalampous