Re: python skipping lines?
- From: Tim Chase <python.list@xxxxxxxxxxxxxxxxx>
- Date: Mon, 27 Nov 2006 13:27:08 -0600
I'm not sure if this will /solve/ your problem, but it's something I noticed...
UnitList = open('/Python25/working/FacList.txt', 'r')
RawData = open('/Python25/working/data.txt', 'r')
Here, you open RawData once...
Output = open('/Python25/working/output.txt', 'a')[cut]
def PullHourlyData(filename, facility, unit):
for line in filename:
counter = 0[cut]
for combos in UnitList:
PullHourlyData(RawData, FacilityName, UnitName)
counter += 1
and your first pass through this loop, you exhaust RawData by reading to the end. The second pass through the UnitList loop, you pass the exhausted RawData to PullHourlyData(). I'm thinking you'd need to RawData.seek(0) or some such "rewind" ability. A slightly ugly alternative would be just opening/closing the RawData file for each pass through the loop. Another, possibly cleaner option (depending on the size of RawData's contents) would be to just read the whole thing into an in-memory list with something like
data = RawData.readlines()
and then just pass "data" to PullHourlyData() each time...no need to rewind (like VHS vs. DVD :)
Part of the confusion stems from the fact that what you refer to as "filename" (sounds like it should be a string containing the path to the file) is actually a file object that contains state.
-tkc
.
- Follow-Ups:
- Re: python skipping lines?
- From: lisa . engblom
- Re: python skipping lines?
- References:
- python skipping lines?
- From: lisa . engblom
- Re: python skipping lines?
- From: Jordan Greenberg
- Re: python skipping lines?
- From: lisa . engblom
- python skipping lines?
- Prev by Date: Re: python skipping lines?
- Next by Date: Re: python skipping lines?
- Previous by thread: Re: python skipping lines?
- Next by thread: Re: python skipping lines?
- Index(es):
Relevant Pages
|