file read array function ?

 
Hello, I have a quick question I was hoping someone could answer. I have a .csv file that I want to extract the information out of and store it in an array. The file is a 2 dimension array and I would like to store the information in a 2 dimension array in my EA. I read through the documantation and I found the example on how to read the csv file, but it looks like it can only read a 1 dimension array. int handle; double varray[10]; handle=FileOpen("filename.dat", FILE_BIN|FILE_READ); if(handle>0) { FileReadArray(handle, varray, 0, 10); FileClose(handle); } My csv file is 10 columns wide by 10 rows so I would like the varray to be[9,9]. Is there a way for this to be done? Or does this function automatically populate my array the way it is meaning the 0, 10 for parameters just denote start and end row for the file to read through. A follow up question. If I have that same file. Is there a way to read and store only 1 column in a 1 dimensional array? Its not that big of a deal if it can't be done. I have a few ideas to work around it. Thanks,
 

Hello free

csv output includes by default the ";" delimiter 0x3B after each datum in one write (if creating a csv and writing 10rows x 10cols)

Opening a csv format file in FILE_BIN mode means reading binary data

eg:

below is csv file in your 10x10 format
below that is the binary content. filereadarray will read enough bytes for each double, and repeat for all doubles. 

IOW not going to work.

IF you used FileReadNumber() x 10 per row; you get first 10cols of row0.

You could populate your double array in construct of two loops with handle mapped to opened file with FILE_CSV|FILE_READ attribs:

example: for(i=0;i<=9;i++) for(j=0;j<=9;j++) array[i][j]=FileReadNumber(handle); //inner loop picks up one rows worth doubles --> [i][0..9]

If you want to mess with files (especially using mql) you should get yourself an editor or hex viewer/editor (I use PsPad is a good freeware editor with tons of features)

A picture as they say tells all and is then more obvious to see why reading binary not work.

/*
0;1;2;3;4;5;6;7;8;0
1;1;2;3;4;5;6;7;8;1
2;1;2;3;4;5;6;7;8;2
3;1;2;3;4;5;6;7;8;3
4;1;2;3;4;5;6;7;8;4
5;1;2;3;4;5;6;7;8;5
6;1;2;3;4;5;6;7;8;6
7;1;2;3;4;5;6;7;8;7
8;1;2;3;4;5;6;7;8;8
9;1;2;3;4;5;6;7;8;9 

*/

Reason: