Unknow data/symbols in the first cell of excel!

 

Hi everyone.

I need a little help with this issue I'm facing. I'm reading an .csv file in mt4 using mql4. The file has 2 columns and 20 rows.

I'm able to read the data from the file but when I read data, in the first cell I get some unknown symbols with my data that is causing problem with my further calculation. Can anyone please tell me what it is.

My file read mode is: FILE_READ|FILE_CSV.

I'm attaching the screen shot of the data I only get for the 1st cell in 1st row only. It will be very kind of you if you let me know what it is and how to get rid of it Or anyway around.

Documentation on MQL5: Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags
Documentation on MQL5: Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags
  • www.mql5.com
File Opening Flags - Input/Output Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Tamur Taj: I'm reading an excel file in mt4 using mql4. The excel file has 2 columns and 20 rows.

Can't be done.

It does not have n × m values. It has formulas, formatting, macros, values, versioning and who know what else. You can't read the propriety binary format.

Save as a CSV, and then you can read that.

 
William Roeder:

Can't be done.

It does not have n × m values. It has formulas, formatting, macros, values, versioning and who know what else. You can't read the propriety binary format.

Save as a CSV, and then you can read that.

Hi William Roeder, Sorry, my bad wrote excel file in typing flow.

Its an .csv file actually. Just getting this strange value at the start of the file while reading in mt4. Please refer to the screenshot attached as file.

 

Code for reading is as following:

extern string fileName = "Alert1.csv";  //File Name
int modeRead   = FILE_READ|FILE_CSV;  //File Opening Mode
string delimeter = ";";               //Parameter of Sepration in File

//Message Array
string msg[n] = {NULL};

void ReadData()
{
   int filehandle = FileOpen(fileName, modeRead, delimeter);

   if(filehandle!=INVALID_HANDLE)
      {
         while(!FileIsEnding(filehandle))
            {
               msg[i] = FileReadString(filehandle);
               //printf(msg[i]);
               SplitString(msg[i]);
               i++;
            }
         FileClose(filehandle);
      }
   else
      Print("Error Opening File.", GetLastError());
}
 
Tamur Taj:

Code for reading is as following:

what application did you use to create the csv file? 

it could be that it is a proprietary format.

 
  1. Paul Anscombe: what application did you use to create the csv file? 

    It also could be Unicode or ANSI; specify in the mode.

  2. Tamur Taj: Code for reading is as following:
    SplitString(msg[i]);

    Don't post code that will not compile. StringSplit - String Functions - MQL4 Reference

 
Paul Anscombe:

what application did you use to create the csv file? 

it could be that it is a proprietary format.

I'm just reading prices and datetime data to make an price and time alert EA.

 
William Roeder:
  1. It also could be Unicode or ANSI; specify in the mode.

  2. Don't post code that will not compile. StringSplit - String Functions - MQL4 Reference

Okay, I'll try Both to check if it solves the problem or not. Regarding point 2 thanks for the tip.

 

Solution to this issue was just to save file as .csv (Comma delimited) file only. Don't use any other formats of csv as excel provides almost 3 of them.

The symbol in the attached screen shot was a BOM i.e. Byte order mark, and it caused by other formats of csv.

So, in order to get rid of it just save the file in simple csv format.

 
Sir I ran into a problem while sending a message by ea to excel sheet (.csv ) file. All the message is being printed in single column of the excel. Can you please help me with this problem? 
Thank you.
 
Sal Mod #: Can you please help me with this problem?
  1. Don't Hijack other threads for your off-topic post. Next time, make your own, new, thread.

  2. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the file.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

    We can't see your broken code.

Reason: