I need to parse a tab delimited text file into a DBF.
Each line ends with ascii(182). Need to read line by line so I can parse and format the data and then put into the DBF. Example code would be most appreciated.
[u]Moderator Notes[/u] (Pablo César) wrote:Message and title have been re-edited also replaced from Self Introduction section, because it contains technical questions. And message/topic title was re-edited.
You need to make your own routine, reading your text in file, line by line. I indicate to you to do it thru low level functions (FOpen, FRead, FClose). These functions you should be aware in Clipper, it's better way and safe.
HMGing a better world "Matter tells space how to curve, space tells matter how to move." Albert Einstein
NickSteel wrote:I'm new to HMG (old to Clipper) and need a little information.
I need to parse a tab delimited text file into a DBF.
Each line ends with ascii(182). Need to read line by line so I can parse and format the data and then put into the DBF. Example code would be most appreciated.
Hi Nick, welcome aboard
The method may depends size of file.
If could you send a little portion ( 10-20 line ) and notify size of file, will be possible suggesting more specific way(s).
The file is huge and has different line formats. Have to do it line by line. If I can get a line in, I can figure out how to parse it. Can you post an example with Fopen(), Fclose(). Long time since I used low level Clipper commands.
%T MEMOTYPE
%F memo_type_id seq_num eps_flag proj_flag wbs_flag task_flag memo_type
%R 921 1 Y Y Y Y General Comments
%R 31323 527 N N N Y SAP Order Header Long Text
%T OBS
%F obs_id parent_obs_id guid seq_num obs_name obs_descr
%R 565 0 America's Capital Projects
NickSteel wrote:Trying everything and failing. Cannot get the code above to compile (syntax error & MAKEARRAY17).
Try to replace this:
Aadd(aLine,&(cLine))
changing to:
Aadd(aLine,cLine)
And let me know is working. This macro character I've have been used due my text in file are with quotes characters at begining and final of each line. But seems is not same case for you...
HMGing a better world "Matter tells space how to curve, space tells matter how to move." Albert Einstein
Function DebugMSG
Local i, aTemp := {}
For i := 1 to pcount()
aadd( aTemp, hb_PValue(i))
Next i
MsgBox(hb_valtoexp(aTemp), "Helpful informations")
Return Nil
Put in you code and call this function like this: DebugMSG(aLine)
This is very clever code! I know it will solve my problem, as it reads the source file line by line.
Thank you and glad to know it has been helpful to you...
HMGing a better world "Matter tells space how to curve, space tells matter how to move." Albert Einstein