Remove headers from Data table

Hi All,

I have to copy a list of line items from SAP like below up to 36 rows, I need to split this into 15 -15 rows as It is accepting only 15 values at a time.

10
20
30
40
50 and so on…

I am copying this data using ctrl+C and getting the data from clipboard and created a data table using generate data table. While pasting the data in SAP I am getting values like

Column1
10
20
30
40
I am not able to remove “Column1” from this .

Can anybody please help me ? As I am stuck with this.

@atishaarav , Is this the Text format of the Datatable that you are pasting in SAP ?

If so, we would require to First remove the First Line and Take all the other lines.

We can do so in the below way :

DT_Text = String.Join(Environment.NewLine,Split(DT_Text,Environment.NewLine).Skip(1).ToArray)

Where DT_Text is the Datatable in Text format

@supermanPunch Thanks for your response .

However I am having confusion in “DT_Text is the datatable in text format” ?

Does that mean the data table is converted to string using Output Data table ?

@atishaarav Yes. Do you have the String format of the Datatable using Output Datatable ? If so, you could substitute the Output variable with DT_Text.

I tried this and tested to check the value of DT_Text using message box.
but I am getting blank value in it

@atishaarav Could You Provide the String Data in a Text file ? Or You Could Debug the Workflow and Show us the Value of the DT_Text before and after the Split in the immediate Panel ?

I am able to remove column1 using above expression and getting appropriate value in string format.

But My challenge is I have to copy first 15 rows and paste into SAP.

So for this again I have converted the string(DT_Tex) into DT using generate Datatable.
and used “Set to clipboard” for pasting data. Still it is pasting like attached image.

Note : I have attached the string in Text file.
image
output.txt (1.5 KB)

@atishaarav ,

We could Prepare a List of 15 Data each, Meaning 15 values Separated by NewLine as one item in the Array.

The Input :
image

The Output :
image

The Expression used :

setList = (From i In Enumerable.Range(0,CInt(Math.Ceiling(CDbl((Split(extractedText,Environment.NewLine).Count-1)/15)))+1)
Let val = String.Join(Environment.NewLine,Split(extractedText.Trim(Environment.NewLine.ToCharArray),Environment.NewLine).Skip(1).Skip(i*15).Take(15).ToArray)
Select val).Where(Function(x)x.Count>0).ToArray

where setList is a variable of Type String Array, and extractedText is the Input Text.

Now using the setList we can Loop Through with For Each and Add only 15 Data each time.

Let us know if you need further assistance

@supermanPunch

Thanks for your response. I was able to get that task done using

DT_Text=String.Join(Environment.NewLine,Split(DT_Text,Environment.NewLine).Skip(1).ToArray)

I used .take() function to take first 15 values from DT.

Regards,
Atish

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.