Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting File Names Based on Day of Week

Status
Not open for further replies.

meker

Programmer
Oct 4, 2000
8
US
Hi,

I receive data files that have a three letter abreviation for the day of the week appended to the end of the file name (example DATA_Mon, DATA_Tue, etc). Each file represents all of the data collected for that day, and must be processed in chronological order. Sometimes I get several of the files at a time, but their time stamps are the same.

Presently, I use a
for fn in `ls -rt $DataDir/DATA*`
statement to loop through the files, but without accurate timestamps this falls short of my needs.

Can anyone suggest how to approach loading the data in the correct order when all you have to sort them by is the name of the file?

Thanks in advance,
Mark
 
How about using a list of the days like this:
Code:
FILELIST="Mon Tue Wed Thu Fri Sat Sun"
for day in $DAYLIST; do
    fn="${DataDir}/DATA_${day}"
 
Raider2001,

I thought about a longer version of this, but then I ran into the problem of processing a Sunday record after a Monday record.

When a connectivity problem arises, I typically receive only two, maybe three files. They are always consecutive days.

This file naming convention I've inherited is just a bad design. If connectivity is down for more than a week, then data is lost altogether. I'm going to push back on the people who are sending me the files so I get proper time stamps and unique file names. I tend to no like doing this, because invariably "they" are going to create something new I have to deal with.

Appreciate your suggestion, though.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top