Page 1 of 1

Assign two or more data files to a dictionary

Posted: July 2nd, 2020, 12:39 pm
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 !!!!

Re: Assign two or more data files to a dictionary

Posted: July 2nd, 2020, 1:57 pm
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");

Re: Assign two or more data files to a dictionary

Posted: July 2nd, 2020, 6:05 pm
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?

Re: Assign two or more data files to a dictionary

Posted: July 2nd, 2020, 11:57 pm
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;

Re: Assign two or more data files to a dictionary

Posted: July 3rd, 2020, 5:42 am
by Boni
Thank you for your kind answer !

Re: Assign two or more data files to a dictionary

Posted: July 3rd, 2020, 9:10 am
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.