I have this dataset:
001abcdefghijklmnopqrstuvwxyz
003jfaoijfpoisajeoaijefoaijofija
005;lksajdf;lkjsafd;lkjdf
006;ldsjfa;ojfda;okjdfa;lkjfda
009;akjfd;lakjfd;lajfd;lakjfd;la
013jjsjfkdjf;ldsajfljkd;fjkdfjdfj
001kfjfdjfkdjfosjisjfojesfljsijfesli <-- New Record
I am using a Script Transformation to transform these rows into columns:
private StreamReader SR;
private string File1;
public override void AcquireConnections(object Transaction)
{
// Get the connection for File1
IDTSConnectionManager100 CM = this.Connections.OILFILEMGR;
File1 = (string)CM.AcquireConnection(null);
}
public override void PreExecute()
{
// Create a reader for File1
base.PreExecute();
SR = new StreamReader(File1);
}
public override void PostExecute()
{
// Close the reader
base.PostExecute();
SR.Close();
}
public override void CreateNewOutputRows()
{
// Declare variables
string nextLine;
int LineNumber;
nextLine = SR.ReadLine();
LineNumber = 1;
while (nextLine != null)
{
//MessageBox.Show(nextLine);
// Add a row
Output0Buffer.AddRow();
Output0Buffer.APINumber = nextLine.Substring(5, 6);
Output0Buffer.County = nextLine.Substring(2, 3);
Output0Buffer.District = nextLine.Substring(14, 2);
nextLine = SR.ReadLine();
LineNumber = LineNumber + 1;
while (nextLine.Substring(0, 2) != "01")
{
if (nextLine.Substring(0, 2) == "02")
{
Output0Buffer.LeaseNumber = nextLine.Substring(5, 5);
}
if (nextLine.Substring(0, 2) == "09")
{
Output0Buffer.FormationName = nextLine.Substring(5, 32);
}
if (nextLine.Substring(0, 2) == "13")
{
Output0Buffer.Latitude = nextLine.Substring(132, 10);
Output0Buffer.Longitude = nextLine.Substring(142, 10);
}
nextLine = SR.ReadLine();
LineNumber = LineNumber + 1;
}
}
}
}
I tried to split the datasets in half, and I noticed that the number of rows being processed went down with each split by half as well. This leads me to believe the code works, but is not closing out correctly. I believe when the last record is recorded, somehow the script errors out.
What am I missing here? Thanks.