xHarbour Reference Documentation > Function Reference |
Parses a delimited text file and loads it into an array.
FParse( <cFileName>, <cDelimiter> ) --> aTextArray
The function returns a two dimensional array, or an empty array when the file cannot be opened.
Function FParse() reads a delimited text file and parses each line of the file at <cDelimiter>. The result of line parsing is stored in an array. This array, again, is collected in the returned array, making it a two dimensional array
FParse() is mainly designed to read the comma-separated values (or CSV) file format, were fields are separated with commas and records with new-line character(s).
See also: | FCreate(), FOpen(), FCharCount(), FLineCount(), FParseEx(), FParseLine(), MemoLine(), MlCount() |
Category: | File functions , xHarbour extensions |
Source: | rtl\fparse.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example reads a CSV file and displays its records // and field data PROCEDURE Main() LOCAL aText := FPparse( "Testdata.csv" ) LOCAL aRecord, cData FOR EACH aRecord IN aText // ? "Record #" + CStr( HB_EnumIndex() ), ": " FOR EACH cData IN aRecord ?? cData + " " NEXT NEXT RETURN
http://www.xHarbour.com