How to write, search in csv

 
Hello, how do I write in the rows and columns of a .csv(a table)? Also how to search for the amount of occurrences and delete occurrences in a .csv?

Code please, as simple as possible 

Thanks in advance 
 
  1. CSV means comma separated values. Extended, the comma can be replaced with other separators. Perhaps you should read the manual. File Functions - MQL4 Reference You write a line with your "columns." Repeat for other "rows."
  2. There is no search. Read a line. Search it. Repeat.
  3. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help
              urgent help.

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum

 
William Roeder:
  1. CSV means comma separated values. Extended, the comma can be replaced with other separators. Perhaps you should read the manual. File Functions - MQL4 Reference You write a line with your "columns." Repeat for other "rows."
  2. There is no search. Read a line. Search it. Repeat.
  3. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help
              urgent help.

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum

How to repeat for other rows or columns? When I use FileWrite it only writes on the first column and FileReadString only reads the first column... 
 

Here is a way of doing it but lets say i want to write hundreds of rows and columns and also read hundreds of rows and columns to count occurrences like a database, how could i do that?

 FileDelete ("test.txt");
  int hnd,pos;
  string txt;

  hnd = FileOpen ("test.txt", FILE_CSV|FILE_WRITE, ",");
  if (hnd > 0)
     {
     FileWrite (hnd, 1.23456, 2.34567,3.45678,4.56789); // first row
     FileWrite (hnd, 9.23456, 8.34567,7.45678,6.56789); // second row
     FileClose (hnd);
     }

  hnd = FileOpen ("test.txt", FILE_CSV|FILE_READ, ",");
  if (hnd > 0)                                           //--- read the file if only hnd is > 0
     {
     //Print ("File size ",FileSize(hnd));
     while (FileTell (hnd)< FileSize(hnd))
     //while (FileIsEnding (hnd) == false)
       {
       pos ++;
       //Print ("Loop number ",pos);  //--- read row number
       //Print ("start file pointer at ", FileTell (hnd),". File size ",FileSize(hnd));

       txt = FileReadString (hnd);   //--- read first column
       //Print (txt);
     
       txt = FileReadString (hnd);   //--- read second column
       //Print (txt);
       
       txt = FileReadString (hnd);   //--- read third column
       //Print (txt);
       
       txt = FileReadString (hnd);   //--- read fourth column
       //Print (txt);
       
       //Print ("End file pointer at ", FileTell (hnd),". File size ",FileSize(hnd));   
       if (FileIsEnding (hnd) == false)
          Print ("File is not ending. More to come");
       }
     
     FileClose (hnd);                                      //--- and so close the file if only hnd is > 0
 
Hgu Gh:

 lets say i want to write hundreds of rows and columns and also read hundreds of rows and columns 

so here is the problem, 

same problem as wanting to calculate an equation once on every bar on chart, 
or looking for an Order with a specific parameter or comment 

there is something that repeats as long as condition is good 

and I believe

William Roeder:
  1. CSV means comma separated values. Extended, the comma can be replaced with other separators. Perhaps you should read the manual. File Functions - MQL4 Reference You write a line with your "columns." Repeat for other "rows."

what you was given by Mr William Roeder has the answer. 

did you even bother to read this.  

funny you doing it to read the files and you don't apply it to writing the files. 

 
Jefferson Metha:

so here is the problem, 

same problem as wanting to calculate an equation once on every bar on chart, 
or looking for an Order with a specific parameter or comment 

there is something that repeats as long as condition is good 

and I believe

what you was given by Mr William Roeder has the answer. 

did you even bother to read this.  

funny you doing it to read the files and you don't apply it to writing the files. 

I did read it
 
Hgu Gh:

Here is a way of doing it but lets say i want to write hundreds of rows and columns and also read hundreds of rows and columns to count occurrences like a database, how could i do that?

Use arrays and/or structures.

 
Seng Joo Thio:

Use arrays and/or structures.

I want to save it as a database 
 
Hgu Gh:
I want to save it as a database 

read using loops, also write using loops, 
save data as arrays so that the loops works well, 
base your database on the array

Reason: