0

I have a flat file whose structure is as

Id  Value
1   1,2,3
2   4,5

The output needs to as

ID  Value
1   1
1   2
1   3
2   4
2   5

I have a flat file source and a script component which is being made as asynchronous. And in the script editor I have written the below code

 public override void Input0_ProcessInputRow(Input0Buffer Row)
        {
              MyOutputBuffer.AddRow(); 
               string[] arr = Row.Column1.Split(',');
              foreach (string s in arr)
              {
                if (!string.IsNullOrEmpty(Row.Column0))
                {
                      MyOutputBuffer.ID = Row.Column0;
                      MyOutputBuffer.Values = s;
                      MyOutputBuffer.AddRow();
                }
              }        
        }
        public override void Input0_ProcessInput(Input0Buffer Buffer)
        {
            while (Buffer.NextRow())
            {
                Input0_ProcessInputRow(Buffer);
            }

            if (Buffer.EndOfRowset())
            {
                MyOutputBuffer.SetEndOfRowset();
            }
        }

But I am getting the below output

Id  Value
NULL    NULL
1   1
1   2
1   3
NULL    NULL
2   4
2   5
NULL    NULL

What is wrong in the program.

Please help

1 Answer 1

1

Got the fix

public override void Input0_ProcessInputRow(Input0Buffer Row)
    {     

        string[] arr = Row.Column1.Split(',');
        foreach (string s in arr)
        {
            MyOutputBuffer.AddRow();
            if (!string.IsNullOrEmpty(Row.Column0))
            {
                MyOutputBuffer.ID = Row.Column0;
                MyOutputBuffer.Values = s;

            }
        }
    }
Sign up to request clarification or add additional context in comments.

1 Comment

You might want to go ahead and flag this as the answer so people know it is answered without having to open. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.