Filewrite to csv and fileread to array from csv

 

does any one can help me to do 

i have two array , array A & array B 

if i want to save array A data to csv then read from csv and to write to array B

how can i code it,thank you!

that is my code blow 

thank you! 

"writefile"
handle=FileOpen(filename,FILE_CSV|FILE_READ|FILE_WRITE);
     
     FileWrite(handle,EntryTrade[0],TimeToStr(EntryTrade[1],TIME_DATE|TIME_SECONDS),EntryTrade[2],EntryTrade[3],EntryTrade[4],EntryTrade[5]
     ,EntryTrade[6],EntryTrade[7],EntryTrade[8],EntryTrade[9],EntryTrade[10],EntryTrade[11],EntryTrade[12],EntryTrade[13]);
     FileClose(handle);


"readfile"

handle=FileOpen(filename,FILE_CSV|FILE_READ);
     FileReadArray(handle,HoldingOrder,0,WHOLE_ARRAY);
     FileClose(handle);
 
handle=FileOpen(filename,FILE_CSV|FILE_READ); 

string holdingArray[14];

for (int i=0; i<ArraySize(holdingArray); i++) {

        holdingArray[i] = FileReadString(handle);

        if (FileIsEnding(handle)) break;

}

FileClose(handle); 
 

Hello, thanks for this example of "reading a CSV file to an array".

I have tested it and see that it is based on the assumption, that we have a "one-dimensional Array".

I would like to read a CSV-file, which has a number of fields per line.

So I suppose this would be a "2-dimensional array".

I would be interested in an example for this case.

Thanks a lot in advance!!

 

Hello, I think I can take back my comment from above.

In fact, what I need is "Array of a structure".

In this case, the Array is still one-dimensional, but it has multiple "columns" with the fields that I want.

So I do not have a question anymore about "2 dimensional".

Tanks a lot in any case!!

 
You can use FileWriteArray() with an array of struct, if the struct is simple enough (no strings etc).
Reason: