GithubHelp home page GithubHelp logo

exploringspansandpipelines's People

Contributors

timiskhakov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wagnerhsu

exploringspansandpipelines's Issues

Line terminator on Windows

On Windows FileGenerator creates a file using a line terminator different from \n that one of the file parsers expects. As a result line parsing breaks while trying to parse a Guid value.

Quick and dirty workaround would be changing the generator to use \n:

public static async Task Generate(string file, int numberOfLines)
{
    var sb = new StringBuilder();
    foreach (var line in CreateContent(numberOfLines))
    {
        sb.Append($"{line}\n");
    }

    await File.WriteAllTextAsync(file, sb.ToString());
}

But a proper solution would be changing the parser to take the Windows version of the line terminator into account.

Thanks to Mark Lynn for pointing out to this issue.

Project RecordParser to automate LineParser generation

Hi, I read your article about how to use span to read files with zero allocation and I find it very releated to my project record parser which is basically a "line parser" which build using the line/fine configurations. It generates using expression tree feature the code you would handwriting yourself using span and all the boilerplate.

It offers builders for read/write files of type delimited (csv, tsv, etc) and fixed-length (cobol, bank stuffs, etc).

anyway, just sharing because I see synergy and may find it interesting in your projects

example:

[Fact]
public void Given_value_using_standard_format_should_parse_without_extra_configuration()
{
    var reader = new VariableLengthReaderBuilder<(string Name, DateTime Birthday, decimal Money, Color Color)>()
        .Map(x => x.Name, indexColumn: 0)
        .Map(x => x.Birthday, 1)
        .Map(x => x.Money, 2)
        .Map(x => x.Color, 3)
        .Build(";");
  
    var result = reader.Parse("foo bar baz ; 2020.05.23 ; 0123.45; LightBlue");
  
    result.Should().BeEquivalentTo((Name: "foo bar baz",
                                    Birthday: new DateTime(2020, 05, 23),
                                    Money: 123.45M,
                                    Color: Color.LightBlue));
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.