string stringData = FileReadString(handle); //This did not work ArrayInsert(stringArray,i,stringData);
Read carefully the doc about FileReadString() & ArrayInsert() :
FileReadString(): returns the line read (string).
ArrayInsert(): inserts the specified number of elements from a source array to a receiving one starting from a specified index.
Hi, i'm in desperate need of help.
I have been trying to load string data from CSV into a string Array in different ways,
tried creating a local string arrayB and passing its only value to string arrayA (main array) with ArrayInsert(arrayA,arrayB,i,0,1) but it did not work either.
If you have any tips, suggestions or solutions, please reply.
I fixed the issue, i was just tired and could not imagine where i was wrong, mods feel free to delete if you want but i did not find any forum post about this topic so the result could be useful for someone in the future...
Here is the result:
//Load data from CSV file to string array void LoadStringsFromCsv(string filename, string &stringArray[]) { int handle = FileOpen(filename, FILE_READ | FILE_CSV | FILE_ANSI); if (handle == INVALID_HANDLE) { Print("Error opening file: " + filename); return; } for (uint i = 0; i <= 100; i++) { string stringData = FileReadString(handle); stringArray[i] = stringData; if (FileIsEnding(handle)) break; } FileClose(handle); }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, i'm in desperate need of help.
I have been trying to load string data from CSV into a string Array in different ways,
tried creating a local string arrayB and passing its only value to string arrayA (main array) with ArrayInsert(arrayA,arrayB,i,0,1) but it did not work either.
I used a very similar method with uint and it worked:
as well as matrixes:If you have any tips, suggestions or solutions, please reply.