Could someone help me convert a string variable to a data table? thank you so much Appreciate your help
please share sample string and expected output sample. Thanks
When string is about CSV have a look at
- Read CSV
- Generate DataTable
1 Like
→ Read Text File
Output-> str_Text (DataType:System.String)
→ Generate DataTable from text
Output-> dt (DataType: System.Data.DataTable)
Regards
1 Like
-
Build DataTable
-
Split string into rows
rows = inputString.Split(Environment.NewLine.ToArray(), StringSplitOptions.RemoveEmptyEntries) -
For Each row in rows
Split each row into columns
columns = row.Split(‘,’.ToArray(), StringSplitOptions.None) -
Add Data Row to DataTable
ArrayRow: columns
DataTable: outputDataTable
1 Like