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 94141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:27:18+00:00 2026-05-10T23:27:18+00:00

I have to read invoice ascii files that are structured in a really convoluted

  • 0

I have to read invoice ascii files that are structured in a really convoluted way, for example:

55651108 3090617.10.0806:46:32101639Example Company               Construction Company          Example Road. 9            9524 Example City 

There’s actually additional stuff in there, but I don’t want to confuse you any further.

I know I’m doomed if the client can’t offer a better structure. For instance 30906 is an iterative number that grows. 101639 is the CustomerId. The whitespaces between ‘Example Company’ and ‘Construction Company’ are of variable length The field ‘Example Company’ could have whitespaces of variable length too however, for instance ‘Microsoft Corporation Redmond’. Same with the other fields. So there’s no clear way to extract data from the latter part.

But that’s not the question. I got taken away. My question is as follows:

If the input was somewhat structured and well defined, how would you guard against future changes in its structure. How would you design and implement a reader.

I was thinking of using a simple EAV Model in my DB, and use text or xml templates that describe the input, the entity names, and their valuetypes. I would parse the invoice files according to the templates.

  • 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. 2026-05-10T23:27:18+00:00Added an answer on May 10, 2026 at 11:27 pm

    ‘If the input was somewhat structured and well defined, how would you guard against future changes in its structure. How would you design and implement a reader?’

    You must define the layout in a way you can flexibly pick it apart.

    Here’s a python version

    class Field( object ):     def __init__( self, name, size ):         self.name= name         self.size = size         self.offset= None  class Record( object ):     def __init__( self, fieldList ):         self.fields= fieldList         self.fieldMap= {}         offset= 0         for f in self.fields:              f.offset= offset             offset += f.size             self.fieldMap[f.name]= f     def parse( self, aLine ):         self.buffer= aLine     def get( self, aField ):         fld= self.fieldMap[aField]         return self.buffer[ fld.offset:fld.offset+fld.size+1 ]     def __getattr__( self, aField ):         return self.get(aField) 

    Now you can define records

    myRecord= Record(      Field('aField',8),      Field('filler',1),      Field('another',5),     Field('somethingElse',8), ) 

    This gives you a fighting chance of picking apart some input in a reasonably flexible way.

    myRecord.parse(input) myRecord.get('aField') 

    Once you can parse, adding conversions is a matter of subclassing Field to define the various types (dates, amounts, etc.)

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

Sidebar

Related Questions

I have read somewhere that HashMap uses chaining to resolve collisions. But if that
I have read a lot that LISP can redefine syntax on the fly, presumably
I have read tutorials and several stack overflow posts that suggest I should use
I have read in a several places (e.g. here ) that I can use
I have read that in 8085 the accumulator is a 8 bit register. Then
I have read that creating a temporary table is best if the number of
I have read that using database keys in a URL is a bad thing
I have read that R uses only a single CPU. How can I let
I have a list of strings that are just invoice numbers. I am enumerating
I have read several articles about UITableView, including the official doc and some on

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.