• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

problem, please help

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a file that is downloaded from a server each day with records on each line. the file is called PUNCH.001. each file contains an X on the 6th element of the first line of the daily PUNCHfile and a Z on the 5th element of the last line of the same daily PUNCHfile. Problem is, sometimes the file gets cut off in the middle and then starts a new PUNCH.002--so..the first file is missing the "Z" line and the second is missing the "X" line. I have to check this file everyday, and if this wierd cutoff thing happens I have to manually cut and paste the two files together, arghh- How would I write a small program to check the PUNCH.001 file to see if there is the 'X' and 'Z' line and if it is missing one, grab the second (punch.002) and put them together. I am kinda new to this stuff so any help is greatly appreciated. thnkas alot.
here is what I have so far:


(edited by Cindy to format code)

[This message has been edited by Cindy Glass (edited May 09, 2001).]
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jake,
Let's see if I'm understanding this:
First Record:
012345X.....
Last Record:
01234Z....
And sometimes, the file doesn't make it all the way to the last (Z) record.....
Why not add a check on your last record to see if it contains a Z in the 5th position?
This isn't "code" - more of a description, but you could develop the code from it:
while(still records)
{
process them as usual
}
//no more records, but the last one will still be in the "buffer"
if (buffer.charAt(5) == 'z') -> close the file //we have all the records
else {
open Punch002 and read the records in
}
Susan

 
Susan Delph
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I couldn't resist....

File test1.txt:
abcdeX
File test2.txt:
abcdZ
Printed on my screen:
abcdeX
abcdZ

I don't know if this is the most efficient/best way to write this -- but it DID check my record from file#1, and when it didn't see a Z, it went and opened the second file....
You'll have to adapt this so that rather than printing to System.out.println, you print to your new output file.
Susan

[This message has been edited by Susan Delph (edited May 10, 2001).]
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic