Skip to content

Commit

Permalink
Support quoted semicolons in csv field values
Browse files Browse the repository at this point in the history
And unskip corresponding unit test
  • Loading branch information
jtellnes committed Feb 16, 2018
1 parent 313a4f4 commit 49677fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void RecordShouldMatch(Record record, int fieldIndex, string name, strin
record.Fields[fieldIndex].Value.Should().Be(value);
}

[Fact(Skip = "Test is for a not yet implemented feature")]
[Fact]
public void SemicolonsWithinQuotesAreNotInterpretedAsFieldDelimiters()
{
AddmlFlatFileDefinition addmlFlatFileDefinition = new AddmlFlatFileDefinitionBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using Arkivverket.Arkade.Core.Addml.Definitions;

namespace Arkivverket.Arkade.Core.Addml
Expand Down Expand Up @@ -52,7 +53,7 @@ private Record GetCurrentRecord()

string currentLine = _lines.Current;

string[] strings = currentLine.Split(new[] {_fieldDelimiter}, StringSplitOptions.None);
string[] strings = Regex.Split(currentLine, $@"{_fieldDelimiter}(?=(?:[^""]*""[^""]*"")*[^""]*$)");

string recordIdentifier = null;
if (_recordIdentifierPosition.HasValue)
Expand Down

0 comments on commit 49677fe

Please sign in to comment.