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…
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"
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)
Thanks for the many suggestions.
I have the opportunity to integrate the input data with a concrete example.
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.