Assign two or more data files to a dictionary

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Boni
Posts: 75
Joined: February 25th, 2020, 5:53 am

Assign two or more data files to a dictionary

Post by Boni »

I can use the "Setfile" function to assign a data file to a dictionary. I would like to know how to do this in case where I want my dictionary browses two or more files to check for a condition. for example, I wrote a loop on a household data file, draw up the list of persons eligible for a specific interview, so how to do it in the case of several data files instead of just one?

Thanks !!!!
Sincerely yours !
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Assign two or more data files to a dictionary

Post by Gregory Martin »

How about creating a function where you do your loop:
function RunTask(string data_filename)

   
setfile(DICT_NAME, data_filename);

    // do something

end;

// ...

RunTask("file1.csdb");
RunTask(
"file2.csdb");
Boni
Posts: 75
Joined: February 25th, 2020, 5:53 am

Re: Assign two or more data files to a dictionary

Post by Boni »

I works, thanks! :D
But, I have a small question, if you do not mind. For synchronization, at the place to write for example: File01.csdb, file02.csdb, ..., to designate files to synchronize or even copy, I can use "* .csdb" or "file??.csdb", to designate all files in this format, I wanted to do in this case it is not working.
So, does it do not in this case or I made a mistake?
Sincerely yours !
khurshid.arshad
Posts: 571
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: Assign two or more data files to a dictionary

Post by khurshid.arshad »

If you have many files for synchronization then use fileconcat Function

See my syntax

Code: Select all

filedelete ("..\104_Data\Listing_NSER\"+"ConL_"+edit("9999999",Pro_Code)+"*.csdb");

fileconcat(LISTING_DICT_NSER,"..\104_Data\Listing_NSER\"+"ConL_"+edit("9999999",Pro_Code)+".csdb","..\104_Data\Listing_NSER\"+"Listing-"+edit("9999999",Pro_Code)+"*.csdb");

		if fileexist("..\104_Data\Listing_NSER\"+"ConL_"+edit("9999999",Pro_Code)+".csdb") then

			if syncconnect(CSWeb, "http://servername IP Address/csweb7_3/api") = 1 then

				setfile(LISTING_DICT_NSER, "..\104_Data\Listing_NSER\"+"ConL_"+edit("9999999",Pro_Code)+".csdb");
				  syncdata(PUT,LISTING_DICT_NSER);
					syncdisconnect();
									 stop(1);

			else
				errmsg ("Internet connection is not working properly.");
				move to Pro_Sup_ID;
			endif;

		else
			errmsg ("You don't have listing data to send on the server.");
			Move to Pro_Sup_ID;
		endif;
Boni
Posts: 75
Joined: February 25th, 2020, 5:53 am

Re: Assign two or more data files to a dictionary

Post by Boni »

Thank you for your kind answer !
Sincerely yours !
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Assign two or more data files to a dictionary

Post by josh »

Usually when we work with csdb files we just a single file rather than multiple files. When using the old file based sync you ended up with one data file per interviewer or sometimes more. With csdb it is easier to just keep everything in one data file so you don't have deal with concatenating and syncing multiple files.
Post Reply