• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Numeric Values
      • String Values
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • StringWriter Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
        • Clear Function
        • Close Function
        • CountCases Function
        • CurrentKey Function
        • DelCase Function
        • DirCreate Function
        • DirDelete Function
        • DirExist Function
        • DirList Function
        • FileConcat Function
        • FileCopy Function
        • FileCreate Function
        • FileDelete Function
        • FileEmpty Function
        • FileExist Function
        • FileName Function
        • FileRead Function
        • FileRename Function
        • FileSize Function
        • FileTime Function
        • FileWrite Function
        • Find Function
        • Key Function
        • KeyList Function
        • LoadCase Function
        • Locate Function
        • NMembers Function
        • Open Function
        • Retrieve Function
        • Set Access Statement
        • SetFile Function
        • Set First Statement
        • Set Last Statement
        • Write Function
        • WriteCase Function
      • Synchronization Functions
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

FileConcat Function

Format
b = fileconcat(ʃdictionary_name,ʅ output_file_name, file_name1ʃ, ..., file_nameNʅ);
Description
The fileconcat function concatenates a number of files into a single file. The files to concatenate can be either individual file names or wildcard file specifications. The function supports two different methods of concatenation:
  • Concatenate cases: Reads cases from each input file and writes them to the output file, skipping invalid and duplicate cases. This mode requires a data dictionary that describes the format of the input and output data files so that cases may be validated and duplicates may be identified. Concatenate cases mode may be used with all types of data sources.
  • Concatenate file contents: Simply appends one file to the end of another regardless of the file contents. This mode will not work for CSPro data sources that are not text (such as CSPro DB data sources).
To peform a case concatenation, you must specify a dictionary_name that specifies the layout of the data files being concatenated. When the dictionary is specified, the files are combined by reading each case from each of the input files and writing them to the output file. In this mode, invalid cases and duplicate cases are automatically removed from the output file.
To perform content concatenation, do not specify a dictionary. In this case, the input files are appended together without examining their contents. This will be faster but will not eliminate duplicates or invalid cases.
The output_file_name is a string expression giving the name of the output file that will contain the concatenated data. The arguments file_name1 to file_nameN are either string expressions or string lists that contain the names of specific files or a wildcard specification of a group of files.
Return Value
The function returns a logical value of 1 (true) if successful and 0 (false) otherwise.
Example 1 - Case Concatenation
fileconcat(CENSUS_DICT, "14combined.csdb", "../Data/14*.csdb");
Example 2 - Case Concatenation With Encrypted Files
If you wish to create an encrypted output file, use a .csdbe extension:
fileconcat(CENSUS_DICT, "output.csdbe", "input.csdb");
In this scenario the user will be prompted to provide a password for the output file. If you prefer to specify the password yourself, include it in the output file specification using a connection string:
fileconcat(CENSUS_DICT, "output.csdbe|password=1234", "input.csdb");
Likewise if the input file was a .csdbe file, the user will have to provide the password during the run; or, you can include the password as a connection string.
Example 3 - Content Concatenation
Content concatenation uses the following syntax:
fileconcat("DMV.txt", "District of Columbia.txt", "Maryland.txt", "Virginia.txt");
See also: FileCopy Function