Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Who's right - me or VFP?
Message
From
03/03/2005 13:49:26
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00991597
Message ID:
00992516
Views:
28
>Hi Cetin, you Turkish delight :-)
>
>Your suggestion to append from ... SDF, instead of repeated LL file handling calls made me think. In the past I've only ever used Append From with structured delimited files, where there's a correlation with my table structure. This case, as you know, was different. I'd never really looked at the SDF clause, finding one to suit from the others. SO I wasn't really aware that you could get the whole line of a source file at once. So I thought, this is equivalent to just having a copy of the source file, but as a table.
>
>After reading (FGET) each line of source it's all just been string manip. to get all the various fields. So, at least for now, I've just converted my sources to tables of 79 char string fields. Then I just scan through the tables, in the same way in which I was chugging through the source, and treat each rec in the same way I was with the FGET string. This is a compromise, rather than implementing full source data conversion to tables, but is the least disruptive to the structure and flow of my existing code and slots in nicely, practically replacing LL command for HL command.
>
>Of course, it's now faster (I wouldn't say dramatically so though), but there's another advantage: before I was FGETting my way through the text file to count how many of different type records (QL, QB, QQ, QR etc.) to get values for my progress thermometer, prior to importing the data. This was quite time consuming in itself. Now I can just use COUNT for lcRecID = "QL", or use INLIST(), etc. (as you said, "QL and QB could be used as filters to get these counts") so, as you can imagine, considerably faster here.
>
>Yeah, so thanks a lot for the tip and stuff. This has been a good improvement. Also makes it less slow when in debug.
>
>Terry

Nice to hear it was of help. I'm not sure about if you noticed the 'tip' burried in 'tip'. You can filter during append. That's for example you can get your 2nd sample txt file's QB and QL lines into 2 separate cursors at once, instead of checking later (thus faster reccount() vs count):

Consider this:
Text to m.lcSample noshow
QB39003800Ipswich:Start BusStop
QL39003800691148621001 town1
QL39003800691149621003 town2
QL39003800691149621005 townEnd
QB39013800Ipswich:Start BusStop2
QL39013800691148621001 town1_2
QL39013800691149621003 town2_2
QL39013800691149621005 townEnd_2
EndText
lcFile = "myBusStops.txt"
StrToFile(m.lcSample,m.lcFile)

create cursor bParent (code c(2),f1 c(4),f2 c(4),description c(50))
create cursor bChild (code c(2),f1 c(4),f2 c(4),lat c(6),lon c(7),town c(10))
select bParent
append from (m.lcFile) for code='QB' type SDF
? reccount(),"Parent"
select bChild
append from (m.lcFile) for code='QL' type SDF
? reccount(),"Child"
index on f1+f2 tag linker
browse nowait
select bParent
set relation to f1+f2 into bChild
browse
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
Next
Reply
Map
View

Click here to load this message in the networking platform