Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6592231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:31:40+00:00 2026-05-25T17:31:40+00:00

Here’s the problem I have, I need to generate a flat string file with

  • 0

Here’s the problem I have, I need to generate a flat string file with a rather complex (imposed) structure based on field length and start and stop positions. It file will be generated from a .Net application (data stored in SQL Server). It has different headers with different templates. The structure might also change overtime. The same type of file will also have to be parsed back into my system.

What I would preferably like is creating a template that defines the look of the file, for example with the following attribute:
Name, Type, Field Length, Start & End Position, Default value.

And be able to generate the file from some kind of view data and then to parse it back from the same template.

I’m pretty sure I’m not the first one to have that kind of trouble, but I cannot find a good library on the Internet. I’ve looked at StringTemplate but it doesn’t seem to be able to create templates based on length and position of data.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:31:41+00:00Added an answer on May 25, 2026 at 5:31 pm

    I don’t know about a generic component which deals with this. But I’d write a generic tool which based on the template definition uses reflection to fill properties in an object.

    Your ‘template’ would need to define the structure of the file, as you already described and the full name of the class you want to load the data into (and perhaps the assembly containing the class if that can change).

    The basic flow would be:

    • Check header for correctness (optional)
    • Loop though the data lines
      • Create new instance of target class (use Assembly.GetType() andType.GetConstructor()`)
      • Loop through the fields
        • Parse value according to their type
        • Set the value of the property with the same name (using Type.GetProperty() and PropertyInfo.SetValue())
      • Add the object to a result collection.
    • Done

    Just make sure your view objects have a default constructor and all the required properties and you should be fine.

    Writing the file can be done much the same way using reflection to get the values of your view object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a problem I ran into recently. I have attributes strings of the form
Here is my problem : I have a post controller with the action create.
Here's my problem I have this javascript if (exchRate != ) { function roundthecon()
Here is what I am trying to achieve in PHP: I have this string:
Here's the problem....I have three components...A Page that contains a User Control and a
Here is my problem...I have a page that loads a list of clients and
Here is an example: I have a file 1.js, which has some functions. I
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.