Reputation:
Is there a method by which one can read just the first record of a file, i.e., to read header information so that a decision can be made whther or not to process the remainder of the file?
I know that with the split transformation component one can write an expression that will ignore all of the rows besides the header based on a key word in the header. I would rather not go that route as that is inefficiently reading every record in the file.
Specifically, is there script component logic that I can implement to close the file and end the dataflow after the first record has been read?
Upvotes: 0
Views: 1740
Reputation: 300489
See this post from Todd McDermid:
Basically, you would set up a Foreach Container to loop over the files in your directory. Inside the Foreach, you would determine the "file type" - perhaps by creating a variable with a long-winded expression on it that pulls apart your file name and assumes the a "file type" value - then passes control on to one of five Data Flows via conditional connectors. (Double-click on the standard green connector, change it's Evaluation Operation to Expression and Constraint, and set the expression to be "file_type_variable = ".) Then each Data Flow picks apart one "file type".
Upvotes: 1