Giter Site home page Giter Site logo

jonataspc / genericparsing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrewrissing/genericparsing

0.0 0.0 0.0 870 KB

GenericParser is a C# implementation of a parser for delimited and fixed width format files.

License: MIT License

C# 100.00%

genericparsing's Introduction

GenericParser

GenericParser is a .NET implementation of a parser for delimited and fixed width format files.

Get Started

Install the latest Nuget package.

Instantiate an instance of the parser:

using (GenericParser parser = new GenericParser(filePath))
{
    while (parser.Read())
    {
      string id = parser["ID"];
      string name = parser["Name"];
      string status = parser["Status"];

      // Your code here ...
    }
}

See below for more examples.

GenericParser Features

  • Efficient
  • Excellent unit test coverage
  • Supports delimited and fixed-width formats
    • For delimited, any custom delimited of a single character is supported
  • Supports comment rows (single character marker)
  • Supports escape characters (single character only)
  • Supports a custom text qualifier to allow column/row delimiters to be ignored (e.g., multi-line data)
  • Supports escaped text qualifiers by doubling them up
  • Supports ignoring/including rows that contain no characters
  • Supports a header row
  • Supports the ability to dynamically add more columns to match the data
  • Supports the ability to enforce the number of columns to a specific number
  • Supports the ability to enforce the number of columns based on the first row
  • Supports trimming the strings of a column
  • Supports stripping off control characters
  • Supports reusing the same instance of the parser for different data sources
  • Supports TextReader and String (the file location) as data sources
  • Supports limiting the maximum number of rows to read
  • Supports customizing the size of the internal buffer
  • Supports skipping rows at the beginning of the data after the header row
  • Supports XML configuration to configure the parser
  • Supports access to data via column name (when a header row is supplied)
  • Supports Unicode encoding

GenericParserAdapter Features (Extends GenericParser)

  • Supports skipping rows at the end of the data
  • Supports adding a line number to each row
  • Supports the following outputs - XML, DataTable, and DataSet

GenericParser - Examples

  • Parsing file from disk
using (GenericParser parser = new GenericParser(filePath))
{
    while (parser.Read())
    {
      string id = parser["ID"];

      // Your code here ...
    }
}
  • Parsing file from stream
using (GenericParser parser = new GenericParser(stream))
{
    // ...
}

GenericParserAdapter - Examples

  • Parsing file into a DataSet
using (GenericParserAdapter parser = new GenericParserAdapter(filePath))
{
    var dsResult = parser.GetDataSet();
}

genericparsing's People

Contributors

andrewrissing avatar holigo1 avatar

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.