Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Importing a text file into VFP
Message
From
19/06/2003 17:10:23
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00801856
Message ID:
00801949
Views:
13
>Hello Esparta,
>I tried {IMPORT FROM C:\Numbers.txt TYPE txt} but it gives a syntax error. I also tried {FILETOSTR(C:\Numbers.txt)} and I'm not sure how to use the {ALINES(ArrayName, cExpression [, lTrim])} command. Is there a way to replace the spaces with a carriage return because that would make it append fine?


You didn't mention which version are you using, but essential ALINES() could do it anyway...

VFP6- (compatible)
lnLines=alines( laWords, chrtran( lcStr, ' ', chr(13) ), .t. )
VFP7/8 Compatible
lnLines=alines( laWords,lcStr," ")
So, to understood your texfile, I've create the followind textfile by code:
lcFile=""
FOR I=1 TO 9
TEXT TO lcFile TEXTMERGE NOSHOW ADDITIVE
<<REPLICATE(TRANSFORM(i),18)>><<SPACE(1)>>
ENDTEXT  
ENDFOR
?lcFile
STRTOFILE(lcFile,"test.txt")
It creates a plain text file with nine number with 18 chars long separated with an space. I'm going to append this file to an cursor via FILETOSTR()+ALINES()+INSERT-SQL
create cursor temp (ccodes c(18))
lcAppend = FILETOSTR("test.txt")
FOR lnCounter=1 to ALINES(laCodes,lcAppend," ")
   INSERT INTO temp VALUES(laCodes[lnCounter])
ENDFOR
But also I can modify the original space separated file to have an enter's delimited file.
STRTOFILE(CHRTRAN(FILETOSTR("test.txt")," ",CHR(13)),"test2.txt")
APPEND FROM test2.txt TYPE SDF
HTH
Apoya a Visual FoxPro usandolo legalmente
--
¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º
Espartaco Palma Martínez
SysOp PortalFox
http://www.portalfox.com
esparta@portalfox.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform