0

Say hypothetically you had a reader which did something like this...

//testing reader, automatically parses strings and converts to the custom type via attributes!
using ( FlatFileReader<MyCustomClass> reader = new FlatFileReader<MyCustomClass>(config) ) {
    MyCustomClass custom;
    while ( (custom = reader.ReadLine()) != null ) {
        Console.WriteLine(custom.ToString());
    }
}

Would this actually be useful in not just flat files, but CSV, etc, etc? I am just having some second thoughts about this program, as to whether it would actually be useful to people. There's not really any technical problems with this, I just want some opinions.

3
Contributors
3
Replies
25
Views
1 Year
Discussion Span
Last Post by ddanbe
Featured Replies
  • 1

    Certainly being able to parse file input into something meaningful is always useful. To make it even more generic, why not use a Stream input instead? That way you can handle any input type (including files, via FileStream) so long as the format is what you expect. Read More

  • 1
    ddanbe 2,525   1 Year Ago

    This [tip](https://msdn.microsoft.com/en-us/library/microsoft.visualbasic.fileio.textfieldparser.aspx?f=255&MSPPError=-2147217396) I got from deceptikon [here](https://www.daniweb.com/programming/software-development/code/468063/how-to-read-lines-from-a-csv-file-). Read More

1

Certainly being able to parse file input into something meaningful is always useful. To make it even more generic, why not use a Stream input instead? That way you can handle any input type (including files, via FileStream) so long as the format is what you expect.

Votes + Comments
Good thoughts!
0

Right, good point. The only reason I am using a config object here is that it is a fixed width file parser. I am probably not using the correct vocabulary in some of the program, but I am essentially passing in a config object which contains a file path, as-well as an array of classes which represent the characteristics of each field, widths, alignment, and field name in case somebody actually wants to print a column header in the file (usually you don't but I have seen some CSV's with this user friendly feature). The idea is I can serialize the configuration object, and reload, etc. The objective in my mind for this program was to make it so that it is useful to different companies/people who may not all have the same fixed width formats.

I could probably think of making a few overloads so I could pass streams to this object, but I would have to think about this to make sure the config object is still useful. Perhaps I should just remove the config object's path/name variable?

Edited by overwraith

1

This tip I got from deceptikon here.

Votes + Comments
Yes, TextReaders are cool, I was just wondering if typed readers would be useful, returns a custom object.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.