How can I delete just one row/line in a csv file?

 

I have a csv file that needs to hold only the last 100 lines of infromation. The csv updates regularly so it needs to remove the oldest line and make room for the new one, in order to keep the number of lines at the maximum allowed 100. If possibile, how can I delete just one line (the first one) in a csv file? If not possibile, then how else could I regularly update a csv file, but at the same time maintain a set number of lines?

Thank you for your time.

 

AFAIK only thru WINAPI

 

@qjol Perhaps you could point me some directions? Where should I look for more information?

Has anyone else faced this problem and worked up a solution? Please share your thoughts, thanks!

 

https://www.mql5.com/en/articles/1540

or maybe u can rewrite the file without the first line

https://www.mql5.com/en/forum/118999

 
Read 100 lines in to arrays, write 99 lines to the file.
 

Hi guys,

This code stores the 10 latest of Open price. Storing and pushing is done in the array with the help of temp array. Then you can write them anywhere you like. Put it as indicator and test it on M1 please. (if anyone wants to share how to do this with bit shifting or other way, I'm all ears!)

//+------------------------------------------------------------------+
//|                                                stack pushing.mq4 |
//+------------------------------------------------------------------+
#property indicator_chart_window

double ad.Open[10];
double ad.Temp[10];

int init()
{
   for (int i=0; i<=9; i++)
   {
      ad.Open[i] = Open[i+1];
   }
   return(0);
}

int start()
{
   if(NewBar())
   {
      for (int i=0; i<=9; i++)
      {
         if (i == 9) 
         {  
            ad.Temp[0] = Open[1];
            break;
         }
         ad.Temp[i+1] = ad.Open[i];
      }
      for (i = 0; i<=9; i++)
         ad.Open[i] = ad.Temp[i];
   }   
   Comment(DoubleToStr(ad.Open[0],Digits) + "," +
           DoubleToStr(ad.Open[1],Digits) + "," +
           DoubleToStr(ad.Open[2],Digits) + "," +
           DoubleToStr(ad.Open[3],Digits) + "," +
           DoubleToStr(ad.Open[4],Digits) + "," +
           DoubleToStr(ad.Open[5],Digits) + "," +
           DoubleToStr(ad.Open[6],Digits) + "," +
           DoubleToStr(ad.Open[7],Digits) + "," +
           DoubleToStr(ad.Open[8],Digits) + "," +
           DoubleToStr(ad.Open[9],Digits) );
   
   return(0);
}
//+------------------------------------------------------------------+
bool NewBar()
{
   static int lastTime;
   if(lastTime != Time[0])
   { 
      lastTime = Time[0];
      return(true);
   }
   return(false);
}