How to avoid that every time i write on CSV file it write row after row?

 

Hello, last time I learned how to avoid that when I write to a CSV it overwrite the same file (  FileSeek(filehandle,0,SEEK_END); )

 

Now my problem is that after writing,even without closing the file, it change row every time it write.

 I also tried with txt file, and it write row after row. 

 I need to write to the same row and I don't know if there is a function for this or if it is possible .

 Actually I use this code

int filehandle=FileOpen("datosbloque2.csv",FILE_READ|FILE_WRITE|FILE_CSV); //FILE datosbloque2.csv // ELIMINATED ,"\t"
           if(filehandle!=INVALID_HANDLE)
                          {
                          FileSeek(filehandle,0,SEEK_END);
                                            FileWrite(filehandle,Symbol(),EnumToString(ENUM_TIMEFRAMES(_Period)),hi,rangoenpuntos,DoubleToString(precioimprimir,5),NormalizeDouble(hhpuntos,5),NormalizeDouble(hhporcentaje,4),horafine );
                                      FileWrite(filehandle,Symbol(),EnumToString(ENUM_TIMEFRAMES(_Period)),hi,rangoenpuntos,DoubleToString(precioimprimir,5),NormalizeDouble(hhpuntos,5),NormalizeDouble(hhporcentaje,4),horafine );
                                      // FileClose(filehandle);
                                      }
                                      else Print("Operation FileOpen failed, error ",GetLastError());
                                                 }

 

 

Thank You. !! 

 
I would read the whole csv-file and split it into an array of line (tab.-row=line), then I would search for the row to be rewritten, rewrite it and save the whole array again.
 
Simo Dodero:

Hello, last time I learned how to avoid that when I write to a CSV it overwrite the same file (  FileSeek(filehandle,0,SEEK_END); )

Now my problem is that after writing,even without closing the file, it change row every time it write.

I also tried with txt file, and it write row after row. I need to write to the same row and I don't know if there is a function for this or if it is possible .

Why is it that newbie coders never bother to read the documentation?

Read the documentation!

Documentation on MQL5: File Functions / FileWriteString
Documentation on MQL5: File Functions / FileWriteString
  • www.mql5.com
File Functions / FileWriteString - Reference on algorithmic/automated trading language for MetaTrader 5
 
Fernando Carreiro:

Why is it that newbie codes never bother to read the documentation?

Read the documentation!

That's not an answer to the question.

There is no need to become angry.

 
Alain Verleyen: That's not an answer to the question.

Yes, it is! Using the FileWriteString and/or other FileWrite??? functions allows you to control when the new line/row is produced and not automatically after the standard FileWrite function, just as the OP requested!

An I quote the docs:

The function writes the value of a string-type parameter into a BIN, CSV or TXT file starting from the current position of the file pointer. When writing to a CSV or TXT file: if there is a symbol in the string '\n' (LF) without previous character '\r' (CR), then before '\n' the missing '\r' is added.

 
Fernando Carreiro:

Yes, it is! Using the FileWriteString and/or other FileWrite??? functions allows you to control when the new line/row is produced and not automatically after the standard FileWrite function, just as the OP requested!

An I quote the docs:

Ok maybe, I understood the question in an other way. We will wait OP answer.

 
Alain Verleyen:
Ok maybe, I understood the question in an other way. We will wait OP answer.
To elaborate, the OP can use the FileWriteString or other FileWrite??? functions several times and it will never generate a new line/row until he finalizes it with a "\n" somewhere in the output.
 
Fernando Carreiro:
To elaborate, the OP can use the FileWriteString or other FileWrite??? functions several times and it will never generate a new line/row until he finalizes it with a "\n" somewhere in the output.

I need to write to the same row and I don't know if there is a function for this or if it is possible .

I think he is asking to update a row, not to avoid to write a new row (CR/LF).

 
Alain Verleyen: I think he is asking to update a row, not to avoid to write a new row (CR/LF).

Since he is Spanish and English is not his mother tongue, it can be interpreted to be either way, but I believe he wants to continue outputting to the same row after each call to FileWrite() and not actually go back and modify the existing output!

We will have to wait for the OP's explanation!

 
Fernando Carreiro:

Why is it that newbie coders never bother to read the documentation?

Read the documentation!

Thank You, I didn't know the function FileWriteString because I am not writing strings but datas as double variables, anyway, I will read and hope to resolve my issue,

 

Thank's to all people who replied !! (If I will have problems I will ask here again ;-)  )  Have a Good programming and a good trading !!

 
Alain Verleyen:

I think he is asking to update a row, not to avoid to write a new row (CR/LF).

Hello, (first, sorry for my English...)

 

What I asked is how to avoid that every time I write to the CSV it change row, I want all data o the same raw, later (if condition is done) I will change row.

 I mean i don't want this:

what I don't want 

I'd like this:

what I'd like

Anyway I have still not read the documentation I received, hope o solve this ;-)

Thank You again !