Inside my DFT
, I have a OLE DB
Source that loads a large data set into my package. The data set has an integer column named TYPE
which its value ranges between 1 to 200. Each type need to be loaded into a separate text file with its name (1.text to 200.txt, a total of 200 text files).
For example, for all records with type 125 a text file with name "125.text" will be created and all rows with type 125 go there. I know that this could be done with Conditional Split
, but it will be ridiculously heavy. So, I just have to find a better way.
I used the following code in C# in a Script Component
and it is working.
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
string path = Path.Combine( "C:\\", Row.TYPE + ".txt");
if (File.Exists(path))
{
using (StreamWriter file = new StreamWriter(@path, true))
{ file.WriteLine(Row.Record);}
}
else
{
File.WriteAllText(@path, "File HEADER " );
using (StreamWriter file = new StreamWriter(@path, true))
{ file.WriteLine("\n");}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.