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

  • SEARCH
  • Home
  • 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 8187933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:44:06+00:00 2026-06-07T02:44:06+00:00

Text file contains order and order detail lines. First line in order header. After

  • 0

Text file contains order and order detail lines.
First line in order header.
After that there is variable number of detail lines.
After detail there is blank line followed by next order etc.
For order line first field is order number.
For detail line first field is 1 always.

128502 02.01.2012 20120 02.01.2012
1   Wine    0   1300
1   Meat    5,8333  5,83

128503 02.01.2012 20123 02.01.2012  
1   Wine    20  130
1   Meat    1,33    283,23
1   Cow 2,333   333,23

....

This file need to be readed into list of entities:

class Order {
  public string Number; // order number from first field, primary key 
  public string Date;
  ... other fields  
}


class OrderDetails {
  public string Number; // order number from previous line , foreign key to Order
  public string ProductName;
  ... other fields  
}

(Instead on Number custom integer id column can also used for relation)

How to read such file in C# ASP.NET MVC2 using FileHelpers library or other way ?

Update

sample

http://www.filehelpers.com/example_multirecords.html

referenced from

Multiple CSV strutures with FileHelpers

shows how to read two tables.
How to create relation between those tables: During reading foreign key to order column should added to details table. How to implement this, getting last order number from previous order line and annd it to detail record ?

  • 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-06-07T02:44:07+00:00Added an answer on June 7, 2026 at 2:44 am

    Well you could go brute force all in one go.
    Read in the entire file
    Split on the blank like.
    Create an Order out of the first line of each split
    Create details out of the rest.

    If the files are huge then you could read in up to each blank line and then process as above.

    Another solution that might have some advantages.

    Run the file through a process that edit’s the detail line and adds in the order number from it’s realted order line.
    Then another that splits out order and detail into two separate files.
    Then process orders then details without having to worry about all this dittoing and two structures.

    Fourth solution, is give whoever came up with this format a good beating to encourage them to do it properly…

    There’s no magic wand solution for this, the file format is simply wholly unsuitable for any efficent passing of data to something that might store it sensibly.

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

Sidebar

Related Questions

I have a text file that contains unix style line endings: a 0x0A at
My text file contains 2 lines: <IMG SRC=/icons/folder.gif ALT=[DIR]> <A HREF=yahoo.com.jp/>yahoo.com.jp/</A> </PRE><HR> In my
I have a text file that contains cached data in JSON format. I'm trying
I have a text file that contains some strings separated by ,. Strings are
I have a text file that contains a list of filenames, minus the extension,
I have Text file that contains data separated with a comma , . How
I have a text file which contains a time stamp on each line. My
My raw input file text file contains a string: Caf&eacute (Should be Café) The
I have a text file which contains data seperated by '|'. I need to
I have a text file which contains something like this: Hello, my name is

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.