Export Data with UUID

Discussions about tools to complement CSPro data processing
Post Reply
YFT_CBSD
Posts: 65
Joined: January 3rd, 2023, 12:36 am

Export Data with UUID

Post by YFT_CBSD »

Hello Everyone,

is there a way to export data with uuid? instead of case_id it will be uuid or caseid+uuid.

Thanks.
Gregory Martin
Posts: 1946
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Export Data with UUID

Post by Gregory Martin »

You can do this in a batch export application but not using the Export Data tool. If you haven't used a batch export before, what you can do is:

1) Open your export specification in Export Data.
2) Select View -> Batch Logic.
3) Click Create Batch Application.

Once you've done this, you'll have a batch export application that exports the data you're interested in. For example, I did this with the Popstan Census dictionary and I get this:
PROC GLOBAL

FILE
cspro_export_file_var_f;

PROC QUEST

PreProc

    set
behavior() export (CommaDelim, ItemOnly, ANSI);

    EXPORT TO cspro_export_file_var_f
    CASE_ID(PROVINCE, DISTRICT, VILLAGE, EA, UR, BUILDING, HU, HH)
    PERSON, HOUSING;
The next step is that you have to add a dictionary item that will contain the UUID. I'll do this using a working storage dictionary:

1) Select File -> Add Files.
2) Click on "Working Storage Dictionary..."
3) Edit the dictionary, adding an item to WS_REC, CASE_UUID, alpha, length 36.

Then I modify the logic to set this value, and to export it:
    CASE_UUID = uuid(CEN2000);
   
    EXPORT TO cspro_export_file_var_f
    CASE_ID(PROVINCE, DISTRICT, VILLAGE, EA, UR, BUILDING, HU, HH)
    CASE_UUID, PERSON, HOUSING;
Now when you run this application, you'll get the UUID in the export.
YFT_CBSD
Posts: 65
Joined: January 3rd, 2023, 12:36 am

Re: Export Data with UUID

Post by YFT_CBSD »

Its working, Thanks Greg!
YFT_CBSD
Posts: 65
Joined: January 3rd, 2023, 12:36 am

Re: Export Data with UUID

Post by YFT_CBSD »

Hi Greg,

I have a question. For example, I have a single .csdb file that contains data for multiple cities/municipalities, and I want to extract the text files separately by city/municipality.

Example:
Input: 01.csdb
Output:
01/01001/cspro_export_file_var_f.txt
01/01002/cspro_export_file_var_f.txt
01/01003/cspro_export_file_var_f.txt
01/01004/cspro_export_file_var_f.txt
01/01005/cspro_export_file_var_f.txt

Thanks
savy
Posts: 201
Joined: December 27th, 2012, 1:36 pm

Re: Export Data with UUID

Post by savy »

You can use setoutput function in a batch application to split the contents of the input data file into one file for each city code;
https://www.csprousers.org/help/CSPro/s ... ction.html
YFT_CBSD
Posts: 65
Joined: January 3rd, 2023, 12:36 am

Re: Export Data with UUID

Post by YFT_CBSD »

Tried the setoutput but when multiple records are set, the output is directed only in a single record, all other records are blanks. Thanks
savy
Posts: 201
Joined: December 27th, 2012, 1:36 pm

Re: Export Data with UUID

Post by savy »

Your logic is not quite right. To get the correct logic, use CSExport tool and set your options correctly. Then click on View->Batch Logic to get the correct logic and paste it into your batch application as Greg mentioned below. For comma delimited export, if you do not want it in a single record, choose "Multiple Files" option and "As separate records"
Post Reply