Popularity
2.7
Stable
Activity
0.0
Stable
89
13
15

Code Quality Rank: L1
Programming language: C#
License: Apache License 2.0
Tags: Linq     CSV     Flat     Files     Import     Export     Tab     Comma     Delimited     FixedWidth     Mapper    
Latest version: v0.9.3

FlatMapper alternatives and similar packages

Based on the "Misc" category.
Alternatively, view FlatMapper alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of FlatMapper or a related project?

Add another 'Misc' Package

README

FlatMapper

Build status NuGet Version NuGet Downloads

FlatMapper is a library to import and export data from and to plain text files in a Linq compatible way.

Features

  • Fast - Only uses Static Reflection and Dynamic methods
  • LINQ Compatible
  • It supports character delimited and fixed length files
  • Non intrusive - You don't have to change your code. Any POCO will work
  • No external Dependencies
  • Iterative reads - Doesn't need to load the entire file into memory
  • Multi-line support (Only on character delimited and quoted)
  • Nullables support
  • Vitually any type support with FieldValueConverters
  • Fluent Interface
  • Per line/record Error handling
  • Simple to use

How to use

Fixed Length Layout

var layout = new Layout<TestObject>.FixedLengthLayout()
                .HeaderLines(1)
                .WithMember(o => o.Id, set => set.WithLength(5).WithLeftPadding('0'))
                .WithMember(o => o.Description, set => set.WithLength(25).WithRightPadding(' '))
                .WithMember(o => o.NullableInt, set => set.WithLength(5).AllowNull("=Null").WithLeftPadding('0'))
                .WithMember(o => o.NullableEnum, set => set.WithLength(10).AllowNull("======NULL").WithLeftPadding(' '))
                .WithMember(o => o.Date, set => set.WithLength(19).WithFormat(new CultureInfo("pt-PT"))); //PT-pt default dates are always fixed 19 chars "13-12-2015 23:41:41"

Delimited Layout

var layout = new Layout<TestObject>.DelimitedLayout()
                .WithDelimiter(";")
                .WithQuote("\"")
                .HeaderLines(1)
                .WithMember(o => o.Id, set => set.WithLength(5).WithLeftPadding('0'))
                .WithMember(o => o.Description, set => set.WithLength(25).WithRightPadding(' '))
                .WithMember(o => o.NullableInt, set => set.WithLength(5).AllowNull("=Null").WithLeftPadding('0'))
                .WithMember(o => o.NullableEnum, set => set.WithLength(10).AllowNull("").WithLeftPadding(' '))
                .WithMember(o => o.Date, set => set.WithFormat(new CultureInfo("pt-PT")));

Reading and Writing

//Reading data
using (var fileStream = File.OpenRead("c:\temp\data.txt"))
{
    var flatfile = new FlatFile<TestObject>(layout, fileStream);
    foreach(var objectInstance in flatfile.Read())
    {
        //Do Somethig....
    }
}

//Writing data
using (var fileStream = File.OpenWrite("c:\temp\data.txt"))
{
    var flatfile = new FlatFile<TestObject>(layout, fileStream)
    flatfile.Write(listOfObjects);
}

For more detailed information please check the wiki