The program code is not mine, but I wanted to modify it to produce an
Analysis folder when the user wants histogram file, basically, a txt
file to appear in Analysis.
Elsewhere in the program this is done for another type of data that is
directed to an Events folder. I figured I could copy the code from there
and use it here. Here's other code for Events.
# He's building a time stamp for the file name.
# I'll use this with a slight modification to the name in
# my code
millisecs = int((event_time - int(event_time))*100)
s = "v%4d%02d%02d_%02d%02d%02d.%02d.dat" % (
t.tm_year, t.tm_mon, t.tm_mday,
t.tm_hour, t.tm_min, t.tm_sec, millisecs )
#OK, he's got the file name assembled
s = os.path.join("Events",s)
if not os.path.exists("Events"):
os.mkdir("Events")
f = file( s, "wb" )
if not f:
self.LogError( "File creation error 1" )
return False
I caused the redundancy by just changing the meaning of s with a new
statement below it. I should have commented the first one out. Yeah, I
probably screwed up here and should have and,for purposes of debugging,
just used another file name like s="ADATAFILE2009_mmdd.txt", which does
not exist at this point of the coding stage. So I should have produced
Analysis\ADATAFILE2009_mmdd.txt. If I had done that then I would have
ended up with an empty file in the Analysis folder. However, even at
that, why can't I delete this empty file called Analysis?
When I said I was able to get rid of the "file", it's probably because I
had rebooted at some time after I puzzled over the problem, and now OS
somehow released it's grip, that is, whatever process was trying to use
the "file" too.
John Machin wrote:
On Dec 5, 9:57 pm, "W. eWatson" <wolftra...@invalid.com> wrote:
[snip]
s = self.current_path
s referred to something ...
s = "Analysis"
but now s refers to "Analysis" ... at best, there is redundant &
confusing code; at worst, the source of your problem.
s = os.path.join("Analysis",s)
and now s refers to r"Analysis\Analysis" (on your platform)
print "s joined ",s <------------- debug print
[snip]
There is no file created, just the folders Analysis\Analysis. One too
many. The second Analysis shows as an icon for a file of size 0KB.
I printed with the debug print above:
Path for Histogram Events\v20070206_055012.06.dat
s joined
Analysis\Analysis should only be Analysis.
Huh?? s = os.path.join("fubar", "fubar") should produce r"fubar
\fubar" (as documented) ... If you don't want s to refer to r"Analysis
\Analysis", then quite simply don't do that!
--
http://mail.python.org/mailman/listinfo/python-list