Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Appending into MEMO fields
Message
From
17/09/1998 10:25:30
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
17/09/1998 07:33:32
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00137715
Message ID:
00137776
Views:
15
>I have a CSV file holding the data for a database that I have exported from MS-WORKS. I am trying to get it into a VFP5 table. I have created a fox table with an appropriate structure, and I am using APPEND FROM TYPE DELIMITED to get the data in.
>
>The problem is, I have some text fields in the CSV which I am trying to put into MEMO fields in the Fox table (they are often > 254 in length) but after the APPEND all the memo fields are blank.
>
>Does anyone have any ideas on how I may get this data in?
>
>Thanks.
Mark,
This one is something you might use. Assumes fox table is ready (structure) in appropriate structure. Sorry no commentation.
*Sample call
*=Delimited2Fox("c:\temp\delfile.txt","c:\myapp\data\mytable")

function Delimited2Fox
lparameters cFileName, cInsertFile
* cFilename - fullname of text file
* cInsertFile - Structure prepared fox table
#define FieldDelimiter "%%%"
dimension aPattern[11,11]
for ix = 1 to 11
	for jx = 1 to 11
	    lcLeft  = iif(ix = 11,["],str(ix-1,1))
	    lcRight = iif(jx = 11,["],str(jx-1,1))
	    aPattern[ix,jx] = lcLeft+","+lcRight
	endfor
endfor
handle = fopen(cFilename)
dimension aParsed[1]
do while !feof(handle)
	=parseline(fgets(handle,65535),@aParsed)
	insert into (cInsertFile) ;
		from array aParsed
enddo	
=fclose(handle)

function parseline
lparameters cLine, aParseArray
local ix,jx
for ix = 1 to 11
	for jx = 1 to 11
	    cLine=strtran(cLine,;
	           aPattern[ix,jx],;
	           stuff(aPattern[ix,jx],2,1,;
	           FieldDelimiter))
	endfor
endfor

lnElements = occurs(FieldDelimiter,cLine)+1
dimension aParseArray[lnElements]
ix = 1
do while occurs(FieldDelimiter,cLine)>0
  aParseArray[ix] = ;
      chrtran(substr(cLine,;
      1,at(FieldDelimiter,cLine)-1),;
      ["],[])
  cLine = ;
      substr(cLine,;
      at(FieldDelimiter,cLine)+;
      len(FieldDelimiter))
  ix = ix + 1
enddo
aParseArray[ix] = chrtran(cLine,["],[])
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform