[Tfug] text file help

christopher floess skeptikos at gmail.com
Thu Jun 26 06:25:28 MST 2008


Alright, I imagine this to be at least in part a sed-type problem. I'd
like to try to figure
it out on my own, but I'm on a time crunch here. I've got a 1300 page document
that needs to be parsed and edited.

It's an inventory list of things in our warehouse that is the only
record of what we
have here before a major software upgrade. It consists of a list of
locations and what
they have in them. The problem is that if a location has 30 of one
thing, that thing is
listed 30 times.

I think the key to getting this file to a more manageable size is
tallying these items
so that they are one line indicating the total quantity in that
location. Here's an
example:

Physical Inventory Detail Report for Univ. of Ariz. Bkst
                                                     Valued at Standard Retail
 Date: 06/20/08                                   UNIVERSITY OF
ARIZONA BOOKSTORES                                       Page:  11
------------------------------------------------------------------------------------------------------------------------------------
PLU \ SKU            DESCRIPTION                               DCC
  QTY        COST    EXT COST
------------------------------------------------------------------------------------------------------------------------------------
Fixture #: 122


                                                      Area Total     585.84
   Area #: 13

883230063751         BELT A REVERSIBLE        /RED     /L      402008
    1       13.21       13.21
883230063805         BELT A REVERSIBLE        /RED/NVY /XL     402008
    1       13.41       13.41
883230063805         BELT A REVERSIBLE        /RED/NVY /XL     402008
    1       13.41       13.41
883230063751         BELT A REVERSIBLE        /RED     /L      402008
    1       13.21       13.21
883230063751         BELT A REVERSIBLE        /RED     /L      402008
    1       13.21       13.21
883230063751         BELT A REVERSIBLE        /RED     /L      402008
    1       13.21       13.21
883230063751         BELT A REVERSIBLE        /RED     /L      402008
    1       13.21       13.21
883230063751         BELT A REVERSIBLE        /RED     /L      402008
    1       13.21       13.21
883230063751         BELT A REVERSIBLE        /RED     /L      402008
    1       13.21       13.21
883230063805         BELT A REVERSIBLE        /RED/NVY /XL     402008
    1       13.41       13.41
883230063751         BELT A REVERSIBLE        /RED     /L      402008
    1       13.21       13.21
883230063744         BELT A REVERSIBLE        /RED/NVY /M      402008
    6       13.41       80.48
883230063805         BELT A REVERSIBLE        /RED/NVY /XL     402008
    6       13.41       80.48
883230063737         BELT A REVERSIBLE        /RED     /S      402008
    6       13.21       79.27

here you can see what's in fixture 122, area 13 and you can see item
#883230063751
is listed 6 times and in fact, the 6th column on any one of those
lines is the quantity
that just happens to be 1 because when we count them, they get tallied one at at
time.

Those six lines could easily be written as one line like this:

883230063751         BELT A REVERSIBLE        /RED     /L      402008
    6       13.21       13.21

Notice how the 6th column now shows a quantity of 6. Well, that is what I think
the key is to reducing the size of this file is and I'm hoping someone
has a clever
solution to it.

Another think to consider is that this item might be in two different
locations, for
instance fixture 231, area 4 in that case, you could want the total of what's in
that location, but not a grand total of what's in both locations. We need the
fixtures to be independent of each other.

I think the sed part wouldn't come in until later when we need to resort this in
to a different order.

Any way, before I end this, I'll just say that his (my boss's) usual way to do
this is to open it with excel and then render it some how from there.
Unfortunately this time the file is bigger and exel keeps crashing
when he does it.

Thanks for any help




More information about the tfug mailing list