cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Text to collection

RajsudhapriyaCN
Level 3

Hi All,

Can anyone help me with developing a code stage with C# or VB to convert text to collection

sample Input:

1.The capital of India.

Moscow

#Delhi

Kabul

Tokiyo

2.The capital of Japan.

Moscow

Delhi

Kabul

#Tokiyo

3.The capital of Afganistan.

Moscow

Delhi

#Kabul

Tokiyo

4.The capital of Russia.

#Moscow

Delhi

Kabul

Tokiyo

Output

32814.png



------------------------------
Rajsudhapriya CN
------------------------------
2 REPLIES 2

Hi,

The easiest way to achieve this without a code stage is by using the BP VBO's such as Strings & Collection Manipulation. 

Steps:

  • Use split lines action from Utility - Strings to convert the text into collection.
  • Use Remove Empty Rows action from Utility - Collection Manipulation to remove any empty rows.
  • Loop the output collection obtained in the above stage.
  • Check if the incoming row has any numbers in the text using regex match (Assuming the question value has a number. Based on the input string you can modify the regular expression) 32803.png
  • If matched, then add a new row to the output collection and set the incoming value as question in the output collection.
  • if not matched, then the set the incoming string as option in the output collection. Use the choice stage and set the options in the output collection accordingly. 32804.png
  • Output Collection32805.png32806.png
  • Workflow32807.png



------------------------------
Athiban Mahamathi ,
SimplifyNext,
Technical Consultant
------------------------------

LakshmiNarayan3
Level 6

Hi

it is not code stage but another simple way

32809.png

Here "Pattern" is regex pattern

(?<Question>\d+.*)[\r?\n]*(?<option1>.*)[\r?\n]*(?<option2>.*)[\r?\n]*(?<option3>.*)[\r?\n]*(?<option4>.*)

Initial string  is your string

32810.png

Output is just undefined collection

32811.png

will get output collection

you can remove first column as below

32812.png

Provide collection name and column name you want to delete

Regards



------------------------------
Lakshmi Narayana
------------------------------