NavigationUser loginWho's new
Who's onlineThere are currently 1 user and 32 guests online.
Online users:
|
Tools - .csv reader!Hi folks, I have a tool today that I hope it's a useful for you as it for me! MQL4 enable us easily to write to csv (Comma-separated values) files. But it's hard to write script that handling reading from csv files and it's hard to make it a fast operation (Just imagine you have a csv file with 100000 record). Our dll today have 4 functions: int gGetRecordsCount(string file_path)Use this function to get how many records in the csv file. You have to pass to it the path and the file name of the csv file. The function will return the count of the records or -1 if there's an error! Example: Alert(gGetRecordsCount("C:\\demo.CSV")); string gGetRecord(string file_path , int record_number)Use function to get a record (line) from a csv file. Just pass to it the path and file name of the csv file and the record (line) number. This function returns the record as string in success. If it couldn't open the file it'll return "NF" and "NL" if the record is empty and "N/A" if the record not found. Example: Alert(gGetRecord("C:\\demo.CSV",1)); int gGetFieldsCount(string file_path,int delimiter)Use this function to get how many fields (columns) the csv has. Pass to the function the path and file name of the csv file and the delimiter character that separate the fields. The function will return the count of the fields or -1 if there's an error! Example: Alert(gGetFieldsCount("C:\\demo.CSV",',')); string gGetCell(string file_path,int record_number , int field_number,int delimiter);Use this function to get a cell in a specified record and specified field in the csv file. Just pass to it the path and file name of the csv file, the record number, the field number and the delimiter character that separate the fields. This function returns the cell as string in success. If it couldn't open the file it'll return "NF" and "NL" if the record is empty and "N/A" if the record not found. Example: Alert(gGetCell("C:\\demo.CSV",1,1,','));
I hope to see your comment and what's else you want me to add to this tool! By codersguru at 2006-04-20 15:26 | Tools | printer-friendly version | login or register to post comments
|