Nancy29
(Dropoffhoney29)
January 17, 2024, 5:15pm
1
Hi All,
I need to create text file and add the datatable values into it by adding individual lines on the page separated by one or two “& vbcrlf &” for line spaces.
Please find below format
Input Datatable :
ID Name company name
1 abc xyz
Output text file: (which is required)
ID 1
Name abc
Company name xyz
Can you please on the same.
Thanks
ppr
(Peter Preuss)
January 17, 2024, 5:45pm
2
Assign Activity
strFlat | String =
(From d In dtData.AsEnumerable
Let rs = d.ItemArray.Select(Function (x,i) String.Format("{0} {1}", d.Table.Columns(i).ColumnName, x.ToString))
From c In rs
Select v=c).Aggregate(Function (x,y) String.Format("{0}{1}{2}", x, vbCrLf, y))
For sure we can also model with essential activities
1 Like
pikorpa
(Piotr Kołakowski)
January 18, 2024, 1:20am
3
Hey @Nancy29
you can also try this:
columnHeaders = dtExample.Columns.Cast(Of DataColumn)().[Select](Function(col) col.ColumnName & " ").ToList()
columnData = dtExample.Columns.Cast(Of DataColumn)().[Select](Function(col) columnHeaders(dtExample.Columns.IndexOf(col)) & String.Join(" ", dtExample.AsEnumerable().[Select](Function(row) row(col).ToString()))).ToList()
working workflow you can find here:
BlankProcess80.zip (2.9 KB)
1 Like
mkankatala
(Mahesh Kankatala)
January 18, 2024, 1:41am
4
Hi @Nancy29
→ Build Data Table
Output= dt_Input
→ Use the below query in Assign activity:
Output= String.Join(vbCrLf + vbCrLf,
dt_Input.AsEnumerable().Select(
Function(row) $"ID: {row.Field(Of String)("ID")}" + vbCrLf +
$"Name: {row.Field(Of String)("Name")}" + vbCrLf +
$"Company Name: {row.Field(Of String)("Company Name")}"
)
)
Output is of DataType System.String
→ Use Write Text File activity to write the output to text file.
Text file Output:
Workflow:
xaml:
Sequence16.xaml (10.6 KB)
Hope it helps!!
1 Like
Nancy29
(Dropoffhoney29)
January 18, 2024, 2:05am
5
Thank you everyone. Will check and work with above methods.
It will definitely help!!
Regards,
mkankatala
(Mahesh Kankatala)
January 18, 2024, 2:16am
6
Hi @Nancy29
If you find the solution for the query after working it out, please mark the post as the solution to close the loop.
Happy Automation!
Regards
system
(system)
Closed
January 21, 2024, 12:47pm
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.