From CSV to XML

Hi everyone.
I need advice on how to structure a bot for converting a file from CSV to XML, with partially variable parts and data.
Let’s say that we start from a CSV, which has a structure like this:
A - introduction
B - supplier name
N* - payments string
C - closing of the file.

the CSV is currently on several lines,clearly.
There are many miscellaneous codes, and among the strings, I have inserted variables that are recalled from a DB. (no problem)

If the Supplier had made only one payment, the creation of the XML would be easy for me.
A+ B + Payment1 + C + “.xml”
(where A, B, N and C are text file notes)

I have a problem when there are multiple payments.
The structure should become
A+ B+ (payment1)+(payment2)+(payment3)… +C

How to understand from the CSV if there are multiple payments?
and so how to cycle this part of the structure n_times?
Thanks a lot…
Aaron

@AaronMark

Initilaize a string variable str with string.Empty

if they are columns after reading the csv into datatble use for each activity with dt.Columns which will loop all columsn and inside it use assign with str = str + dt.Rows(0)(currentItem.ColumnName).ToString

If they are in rows then use for each row in dattable and then inside use assign with str = str + currentRow("ColumnYou need").ToString

after loop add str = str + ".xml"

cheers

Hi @AaronMark - I have created a dummy test data and sample code which can give you the intended output. I have used Invoke code activity which is somewhat C# code. But you can always filter by “B - Supplier” first and then loop through all the values and appending each of them as provided by @Anil_G.

Here is the attached code and sample data, if it can be of any use. Please let me know your thoughts.
Main-3.xaml (12.7 KB)
TestData.xlsx (14.2 KB)

Hi everyone.
Thanks for the many suggestions.
I have the opportunity to integrate the input data with a concrete example.

id pa_id_istat pa_id_cat pa_id_fiscal_code pa_id_cbill pa_pec_email pa_referent_email pa_referent_name amount debtor_id_fiscal_code debtor_name debtor_email payment_notice_number
1 10101 F001 012345678901 A0001 mail@mail.com xxx.xxx@mmm.com JohnJ 20048 123456489 Enterprice utility@face.com 123456789
2 10101 F001 012345678901 A0001 mail@mail.com xxx.xxx@mmm.com JohnJ 500 123456489 Enterprice utility@face.com 123456789
3 10101 F001 012345678901 A0001 mail@mail.com xxx.xxx@mmm.com JohnJ 124 123456489 Enterprice utility@face.com 123456789
4 20202 F001 12345688888 A0002 white@test.com xxx.xxx@xxxx.com Smith 100 123456489 Enterprice utility@face.com 123456789

This grid is an example of a plausible csv input file.
Id Number indicates the line number.
The second column, pa_id_istat, and the fourth, fiscal code, indicate the customer.
Lines 1, 2,3 are the payments of the first customer.
line 4 of a second customer.

In the logic expressed above, the xml file must contain a fixed “personal data” part for each customer and in the central body, it must cycle a series of information relating to individual payments for each customer.
There will then be a third part code closure for the first customer,
and opening the code for the next customer.

I am autonomous in identifying with MySQL, and grouping and counting the occurrences of each customer, but as I said above, I don’t know how to cycle the central part of each payment.

PS: I was unable to open the attached w.flows. I have UiPath 20.10.10 right now.
Thanks!
Aaron