Customer Portal

How to validate file structure against meta data

Comments 1

  • Avatar
    novakj
    0
    Comment actions Permalink
    Hello Martin,

    Regarding your questions:

    1. You have to set in the metadata exactly the same number of fields as a number of columns you expect in your CSV file. If you have in your CSV file different number of columns than what is defined in the metadata, it will cause error.

    2. and 3. You can access dynamically in the CTL to the record's fields, for more details please see the documentation:
    http://doc.cloveretl.com/documentation/UserGuide/index.jsp?topic=/com.cloveretl.gui.docs/docs/field-access-functions-ctl2.html

    4. You can throw your own error in the CTL by the function
    raise_error(string)
    This function takes one string argument and throws out error with the message specified as the argument.

    I prepared for you sample demo of your desired functionality (points 2, 3 and 4), so please take a look into the sample project. It demonstrates reading CSV file, parsing first line and checking headers of columns. If the CSV file has not headers of columns named as the fields of metadata or if the CSV file has columns in different order, the error is thrown. There is a sample CSV file located in data-in/data.csv.

    I hope this sample will help you to find your solution.

Please sign in to leave a comment.