Jump to content
  • entries
    0
  • comments
    0
  • views
    180

Tasks and their Solutions


On rare occasions I'll have a request from management or customers to "data mine" and appropriate the data into sorted criteria based on their needs. The majority of the time the process is tedious and obnoxious and I'm always trying to find quick solutions and answers to problems.

 

Today was one of those days. I work in a Logistics firm, and as such our Warehouse/Transport Management system is the whole back bone of our business, however getting data out of it in a nice view is an absolute PITA.

 

We have a list called our Delivery Point locations which we show customers and potential customers, showing our market reach, however this list hasn't been updated since 2007 and is in need of refreshing.

 

Simplistic output however the process is a nightmare, and I've found a nice tidy solution to fix this data mine. The data is going to be collected from Orders despatched, focusing on "Delivery Point Code" and "Delivery Address"

 

The process as follows.

 

1. WMS System > Transport > Orders Despatched

2. Select date range to show 01/07/09-30/07/09

3. Export Data

4. 25 Colums and 171,343 lines of Data. Most of this is duplicated deliveries as we deliver to multiple locations every day.

 

Herein lies the problem, grabbing individual data and stripping duplicates.

 

1.) Open the CSV and remove any fields/columns that aren't needed leaving on the two required. Delete anything local (I.e. Collections from XYZ to Base)

2.) Notepad++ - Convert everything to uppercase

3.) Copy CSV onto Linux System

4.)

Sort filename.csv > output.csv

(Putting all the duplicates next too each other)

5.)

uniq -w 6 output.csv finished.csv

 

Reason behind the counting of words to 6 characters. Our delivery point location codes are 6-digits long, however the Address can be different even for the same location as this is a manual process. For example.

 

TESDID, Tesco Didcot

TESDID, Tesco Didcot Warehouse

TESDID, Tesco Didcot

 

When using "uniq" it would only remove one TESDID and leave the two uniqs alone, and this in itself is wrong, hence only counting the first 6 characters of the code and stripping/ignoring the rest.

 

In the end, the process took 3 minutes, compared to what seemed like forever in Excel sorting fields, filtering and manually deleting duplicates. I got bored with 169,000 lines left and search for an alternative.

 

End result. Task completed faster than expected and my sanity remains intact.

 

Just wanted to share this, albeit not very relevant, but the tedious/tasks that we are sometimes asked to provide.

8 Comments


Recommended Comments

localzuk

Posted

There is another option, you could put the data in an SQL database and use UNIQUE/DISTINCT and GROUP BY commands with a SELECT command. This way, you can just pull the data out as and when you want to.
ahuxham

Posted

There is another option' date=' you could put the data in an SQL database and use UNIQUE/DISTINCT and GROUP BY commands with a SELECT command. This way, you can just pull the data out as and when you want to.[/quote']

 

 

The data is all in SQL to start with. However I have no idea what commands to be typing.

 

Any ideas?

ahuxham

Posted

Take a look at this page' date=' explains 'DISTINCT' quite well SQL DISTINCT

 

GROUP BY is here:

SQL GROUP BY

 

Oh dear :(

 

SELECT DISTINCT DELCODE, DELENDPOINT

FROM TMS_ORD_DESP

 

Would infact give me what I wanted :(

 

Lets say we have A,B,C Customers, and each customer has their delpoints assigned. Albeit we assign these.

 

Cust A has del TESBIR as Tesco Birkenhead

Cust B has del TESBIR as Tesco Birkenhead

Cust C has del TESBIR as Tesco Birmingham.

 

The above command would filter out Cust B, and leave cust A and C since they're different?

p858snake

Posted

Since this was in csv format, couldn't you open in a speadsheet application such as excel then sort by the required column, and then you could easily delete any rows that are duplicates (i believe you can use conditional formatting as well to pick it up in 2007)
localzuk

Posted

Sorting 170k rows, and doing that amount of processing in Excel isn't gonna work very well - it isn't designed for that. The data, as ahuxham says, is already in an SQL DB, so just calling a SQL command is the simplest way of doing it.

 

And in reply to Ahuxham, yes, customer B would be ignored as a duplicate.

ahuxham

Posted

Since this was in csv format' date=' couldn't you open in a speadsheet application such as excel then sort by the required column, and then you could easily delete any rows that are duplicates (i believe you can use conditional formatting as well to pick it up in 2007)[/quote']

 

 

Too time consuming hence ruffling my feathers trying to find an easy solution.

 

My Uniq and Sort solution takes about 10 minutes per CSV output.

 

However LocalZ's method takes a matter of seconds, and I can quickly export rough delivery point codes for a single year, selecting month ranges at a time and compare the files and get a more accurate delivery point list.

 

Thanks LZ

localzuk

Posted

Another thing - you could utilise a view with the command instead - then you just need to open it whenever you want to get the data.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...