Skip to content

Commit

Permalink
Changing named temporary file to be compatable with windows
Browse files Browse the repository at this point in the history
  • Loading branch information
denvaar committed Jan 27, 2016
1 parent b96a20e commit 271e34d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/StreamingDataLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def main(arguments):
logger.setLevel(logging.INFO)

# Set up logger to log to a file.
if not os.path.exists(LOG_FILENAME):
os.makedirs(LOG_FILENAME.strip('logfile.txt'))
handler = logging.FileHandler(LOG_FILENAME)

# Set up the formatting of the log strings.
Expand Down Expand Up @@ -107,10 +109,10 @@ def main(arguments):
logger.debug('Writing %s...' % table[0])
# If able to save table to database...
if dataMapModel.save(table[1]):
print "COLUMNS"
print table[1].columns
print "VDT"
print type(table[1]['ValueDateTime'])
#print "COLUMNS"
#print table[1].columns
#print "VDT"
#print type(table[1]['ValueDateTime'])
# Update the latest date time for the table.
dataMapModel.updateDateTime(table[1]['ResultID'][0],
np.max(table[1]['ValueDateTime']))
Expand Down
1 change: 1 addition & 0 deletions src/controllers/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import sys
import logging
from datetime import datetime



Expand Down
5 changes: 3 additions & 2 deletions src/handlers/csvHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ def byteReader(self, filepath, start_byte, datecol, header=0, sep=None, dataBegi
data = response.read()
#filepath = StringIO(data)

temp = tempfile.NamedTemporaryFile()
temp = tempfile.NamedTemporaryFile(mode='w', delete=False)
tempName = temp.name
try:
temp.write(data)
temp.seek(0)
finally:
#print temp.name
df = self.byteReader(temp.name, start_byte, datecol, header, sep, dataBegin)
df = self.byteReader(tempName, start_byte, datecol, header, sep, dataBegin)
temp.close()
return df
#return self.byteReader(filepath, start_byte, datecol, header, sep, dataBegin)
Expand Down

0 comments on commit 271e34d

Please sign in to comment.