16-01-19 01:46 PM
19-01-19 01:16 AM
You need to have something that defines the column with typeof(String) Here's a C# action I wrote that'll handle CSVs with custom delimiters.
Inputs:
Delimiter - Text
Target - Text
headers - Flag
Outputs:
Collection - Collection
var file = Target; var parser = new TextFieldParser(file); var dt = new DataTable(); parser.SetDelimiters(Delimiter); string temp = ""; int count=0; while(!parser.EndOfData) { if(count==0) { string[] columns = parser.ReadFields(); if(headers) { foreach(string title in columns) { string colName = title; int num=0; while(dt.Columns.Contains(colName)) { colName = string.Format("{0}_{1}",title,++num); } dt.Columns.Add(colName, typeof(String)); temp+=title; } } else { int fields = columns.Length; int colCount=1; while(colCount<=fields) { string colName="F"+colCount.ToString(); dt.Columns.Add(colName, typeof(String)); colCount++; } var dataTableRow = dt.NewRow(); dt.Rows.Add(columns); } } else { var dataTableRow = dt.NewRow(); dataTableRow.ItemArray = parser.ReadFields(); dt.Rows.Add(dataTableRow); //csvData.Rows.Add(fieldData); } count++; } Collection = dt; row = temp;
30-01-19 02:47 PM
30-01-19 03:09 PM
01-02-19 08:34 PM
I've got this action in the middle of a bunch of other custom collection manipulation actions, so I'll just put all of the includes I put on the object. It's a bit of a shotgun blast and may import more than you actually need, but it should fix it. Please note that the file path has no quotes, and that the language is still C# despite the external ref and namespace for VB.
External Refs:
System.dll
System.Data.dll
System.Xml.dll
System.Drawing.dll
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Core.dll
Microsoft.VisualBasic.dll
Namespace Imports:
System
System.Drawing
System.Data
System.IO
Microsoft.VisualBasic
System.Collections.Generic
System.Text
System.Linq
Microsoft.VisualBasic.FileIO
19-02-19 10:01 PM
20-02-19 02:31 AM
20-02-19 01:33 PM
11-10-19 01:19 PM
11-10-19 04:41 PM