| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Parses one line of a delimited text and loads it into an array.
FParseLine( <cTextLine>, [<cDelimiter>] ) --> aTextFields
The function returns a one dimensional array, or an empty array when an error occurs.
Function FParseLine() parses one line of delimited text at <cDelimiter>. The result is stored in a one dimensional array.
FParseLine() is mainly designed to process the comma-separated values (or CSV) file format, were fields are separated with commas and records with new-line character(s).
Note: function FParse() is available to process an entire CSV file.
| See also: | FParse(), HB_FReadLine(), MemoLine() |
| Category: | File functions , xHarbour extensions |
| Source: | rtl\fparse.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example parses one line of delimited text and displays
// the resukt. Note that commas exist in the first and sixth
// text field of the CSV formatted string.
PROCEDURE Main()
LOCAL cText, aData
cText := '"Jones, Mr",Male,"Oklahoma","IL",20041231,"Director, President"'
aData := FParseLine( cText )
FOR EACH cText IN aData
? LTrim( Str( HB_EnumIndex() ) ), cText
NEXT
** Output
// 1 Jones, Mr
// 2 Male
// 3 Oklahoma
// 4 IL
// 5 20041231
// 6 Director, President
RETURN
http://www.xHarbour.com