Code Monkey home page Code Monkey logo

Comments (2)

MarkPflug avatar MarkPflug commented on July 18, 2024
  1. I'm assuming your file has a header row? Otherwise, you wouldn't be able to map my name alone as the columns don't have names. You can use the Schema type to map the named columns to their own name: Schema.Parse("Name>Name,LastName>LastName,BirthDay>BirthDay:DateTime"). This ">" syntax maps the "base column name" (the name in the file) to the name that it will be exposed as through the CsvDataReader. You could also implement your own mapping mechanism by implementing your own CsvSchemaProvider.

  2. Using the above mapping technique, you can check via GetOrdinal which will throw an exception if the name doesn't exist. Or, you can use the GetColumnSchema method to get the exposed schema and verify that all the expected columns are present.

  3. I would expect that to "just work", so maybe I don't understand what you're asking.

  4. You can use the Validate or ValidateSchema extension methods (in Sylvan.Data) which allow you to handle data validations. These methods allow you to provide a validation method, which will be called for all rows (Validate), or only called for rows that don't match the expected schema (ValidateSchema). ValidateSchema is probably what you want; your validation method will only be called when the date value can't be parsed correctly. In your validation method you can try to "repair" the data. The DataValidationContext parameter has methods to determine what columns have errors (GetErrors/GetException), and methods to allow you to provide a value (SetValue). You can return true if you could repair the data and want it to be yielded from the reader, or false to skip the row altogether, and maybe log the failed row somewhere.

Hopefully that helps, but I'm not sure I was understanding your issues so let me know if I did.

from sylvan.

MarkPflug avatar MarkPflug commented on July 18, 2024

I'll assume, at this point, that you got things working...

from sylvan.

Related Issues (20)

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.