Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ParseCSVLine.cs to fix the behaviour in case of null or missing values #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions encog-core-cs/Util/CSV/ParseCSVLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,20 @@ private IList<String> ParseCharSep(string line)
char ch = line[i];
if ((ch == Format.Separator) && !quoted)
{
//If value is empty string, that means value is missing, in Encog terms unkown or missing value is represnted with "?"
if (item.Length == 0)
{
item.Append("?");
}
String s = item.ToString();
if (!hadQuotes)
{
s = s.Trim();
}
result.Add(s);
item.Length = 0;
//We just process "a seperator" that means we are expecting value after the sperator, if it does not present then "?" is going to be the default value. which means missing value in Encog terms.
item.Append("?");
quoted = false;
hadQuotes = false;
}
Expand All @@ -86,6 +93,11 @@ private IList<String> ParseCharSep(string line)
}
else
{
//We found as valid value so remove the missing value character.
if (item.ToString() == "?")
{
item.Length--;
}
item.Append(ch);
}
}
Expand Down