Extract a Table from JIRA Comments and add in datatable

I get JIRA Ticket comments and save it in Comments Variable type (Text_data).
It contains a table which i need to extract.
The table looks like this in Text_data after extracting the BODY :slight_smile:

@β€œ|Quantity|Material |Material Name|
yes/no|Defect|
|1x|33142833|REMOTESET|No|300|
| | | | | |
| | | | | |
| | | | | |
| | | | | |”

I am trying to use the names as header and the information stored in each variable in datatable.
I am not getting rid of
| | | | | |
| | | | | |
| | | | | |
| | | | | |"
as well as the names are not taken as header column names.

Can anyone help to extract the info to save it in the datatable.
Thanks

You can apply the below.

lines = rawText.Split({Environment.NewLine}, stringSplitOptions.RemoveEmptyEntries).ToList()

Build a datatable with predefined columns

Use For Each Loop for lines

  1. columns = line.Split("|"c, StringSplitOptions.RemoveEmptyEntries).Select(Function(x) x.Trim()).ToArray()
  2. Use Add Datarow activity and pass this value in that
    {columns.ElementAtOrDefault(0), columns.ElementAtOrDefault(1), columns.ElementAtOrDefault(2), columns.ElementAtOrDefault(3), columns.ElementAtOrDefault(4)}

Once your output table is ready you can remove row at index 0 using the Remove Row activity as that row contains the name of the columns as it was coming in the raw text.

have a look at the following activity which allows you to parse the text into a datatable:

I defined lines as - list(String) and Columns as String.
Is it correct?

My column output looks likes this:

string[35]
{
β€œQuantity”,
β€œMaterial”,
β€œMaterial Name”,
@β€œyes/no”,
β€œDefect Material”,
β€œβ€,
β€œ1x”,
β€œ33”,
β€œREMOTE SET”,
β€œNo”,
β€œ30”,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€,
β€œβ€
}

Found a solution.
Separated Header and data like this:

Column = rawText.Split("|"c, StringSplitOptions.RemoveEmptyEntries).Select(Function(x) x.Trim()).ToArray()

Header = Column.Take(5).ToArray()
Data = Column.Skip(6).Take(column.Length).ToArray().Where(Function(s) Not String.IsNullOrWhiteSpace(s)).ToArray()

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