Codification Issue

36 views
Skip to first unread message

Rick Rauschke

unread,
Apr 6, 2014, 12:49:07 AM4/6/14
to accor...@googlegroups.com
Greetings, I'm getting the following error when trying to apply a Codification 'codebook' to a DataTable obj per the example found at http://accord-framework.net/docs/html/T_Accord_Statistics_Filters_Codification.htm

"Additional information: Cannot set column 'F2'. The value violates the MaxLength limit of this column."

This is the only code in the test class Main:

ExcelReader db = new ExcelReader("somefilenamehere.xlsx", false, true);
DataTable table = db.GetWorksheet("test");
Codification codebook = new Codification(table);

>>>>> exception here >>>>>> DataTable result = codebook.Apply(table);

An example of the records being read is as follows (note, the codebook is properly identifying the string-type columns and enumerating the values properly)

0,tcp,ftp_data,SF,491,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,1,0,0,150,25,0.17,0.03,0.17,0,0,0,0.05,0,normal

(It is indeed the NSL-KDD network intrusion dataset!)

Any help or direction is greatly appreciated.

Regards



Rick Rauschke

unread,
Apr 6, 2014, 12:50:43 AM4/6/14
to accor...@googlegroups.com
I should add, although I pasted the CSV version of the single record, I did this only for formatting purposes - the file being read is indeed in .xlsx format.

César

unread,
Apr 6, 2014, 7:19:46 AM4/6/14
to accor...@googlegroups.com
Hi Rick!

Thanks for reporting the issue. This problem seems to occur whenever the codification filter is applied to a table that has been loaded using a database or the Excel parser and the original schema definition included a max length for the string columns. I have just fixed the issue in the current development branch, but I can also propose you a workaround until the next release comes out. It seems that if you remove the max length restriction before the column is converted, it seems to work:

    foreach (DataColumn col in table.Columns)
   
{
       
if (col.DataType == typeof(string))
            col
.MaxLength = int.MaxValue;
   
}

   
DataTable result = codebook.Apply(table);


Hope it helps!

Best regards,
Cesar

Rick Rauschke

unread,
Apr 6, 2014, 11:25:27 AM4/6/14
to accor...@googlegroups.com
Greetings Cesar,

I will follow your suggestions and appreciate you taking the time to reply so quickly.  Thanks to you and all involved for this amazing framework!

Kind regards,
Rick
Reply all
Reply to author
Forward
0 new messages