Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Data from tab delimited file to a cursor
Message
From
28/10/2003 15:52:14
 
 
To
28/10/2003 14:27:47
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00843661
Message ID:
00843770
Views:
28
Are there quotes around each field? If not, you can try something like (substitute your file name for test.sdf):
lnMaxRowWidth = 345
lnFields = ceiling(lnMaxRowWidth/254)
dimension arrFields[lnFields,4]
arrFields = 0
for ix=1 to lnFields
  arrFields[ix,1] = 'f'+ltrim(str(ix))
  arrFields[ix,2] = 'C'
  arrFields[ix,3] = iif(ix=lnFields,lnMaxRowWidth-(254*(ix-1)),254)
ENDFOR
create cursor junkpos from array arrFields
append from test.sdf type SDF
GO top
dimension myfields(1,4)
lnlength = 0
lilength = 0
lncount = 1
DIMENSION myfields(lncount,4)
myFields[lncount,1] = 'f'+ltrim(str(lncount))
myFields[lncount,2] = 'C'
myfields[lncount,3] = 10
myfields[lncount,4] = 0
for i = 1 TO LEN(junkpos.f1)+1
	lnlength = lnlength + 1
	IF ASC(SUBSTR(junkpos.f1,i,1))=44
		lncount = lncount + 1
		DIMENSION myfields(lncount,4)
		myFields[lncount,1] = 'f'+ltrim(str(lncount))
  		myFields[lncount,2] = 'C'
		myfields[lncount,3] = lnlength-1
		myfields[lncount,4] = 0
		IF lnlength > lilength
			lilength = lnlength
		ENDIF
		lnlength = 0
	ENDIF
ENDFOR
FOR i = 1 TO ALEN(myfields,1)
	IF myfields(i,3) < lilength
		myfields(i,3) = lilength
	ENDIF
ENDFOR
create cursor junkpos from array myFields
APPEND FROM test.sdf DELIMITED WITH "" WITH CHARACTER ','
browse
I'm sure there is a better way. You can certainly improve this down and dirty code! :o)

>Jim and Tracy,
>
>After looking at the text files, I realize that the data is COMMA delimited, not TAB delimited. Sorry for the mis-information. Everything (header row, and data) is comma delimited. I can open it into an Excel spreadsheet using the comma delimiter option with no problem.
>
>Is this this info you were looking for?
>
>Joe
>
>
>>I see.
>>
>>>Tracy,
>>>
>>>Typically CHR(10), but I don't know this is the case with Joe's data set. I suspect there is no record delimiter, you just have to know how many tab-delimited fields constitutes a "record".
>>>
>>>That's what I'm trying to find out -- is there, in fact, a record delimiter in the text file.
>>>
>>>Regards,
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform