CSPRO Lookup table

Other discussions about CSPro
Forum rules
New release: CSPro 8.0
Post Reply
langsonb
Posts: 4
Joined: December 3rd, 2020, 1:38 pm

CSPRO Lookup table

Post by langsonb »

Hi everyone,

I have a big database covering 52 districts. Is there a way I can add files (Lookup files) using command and on condition.
For example can I load cases for District 1 only when the user opens the app on the tablet? I am asking this question because add files
adds the entire file with all 52 districts and makes app slow.

Thanks :|
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: CSPRO Lookup table

Post by josh »

You could create separate lookup files for each district or region using a consistent naming scheme like region01.csdb, region02.csdb,... and then use setfile() to attach the appropriate file to the dictionary you are using. Not sure that would be much faster since there is some overhead to open the data file when you call setfile().

If you are just using loadcase() then it should be very fast even with extremely large files since it uses the index to do the lookup so it does not need to read the whole file. If you are using forcase to loop through the file then that will be slow on large files. For example if you are using the lookup file to load all villages in a given district using forces that can be slow. You can make it fast by changing the structure so that each district is a case with a multiplying occurring record (roster) of villages. Then you call loadcase with the district code and get all the villages. Alternatively in that case you can use the locate() function to jump directly to the first village in the district and then use while loadcase() to loop through the villages.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: CSPRO Lookup table

Post by Gregory Martin »

Take a look at startswith: https://www.csprousers.org/help/CSPro/s ... ction.html

You can use this in a forcase statement to greatly speed up your loop.
Post Reply