Skip to content

Instantly share code, notes, and snippets.

@lisitsyn
Created September 26, 2012 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lisitsyn/3789950 to your computer and use it in GitHub Desktop.
Save lisitsyn/3789950 to your computer and use it in GitHub Desktop.
import csv
import numpy
import time
class operation():
def __init__(self, msg):
self.msg = msg
def __enter__(self):
print 'Starting %s' % self.msg
self.start = time.time()
def __exit__(self, type, value, traceback):
print 'Finished %s, it took %fs' % (self.msg, time.time()-self.start)
with operation('reading files'):
with open('train.csv', 'rb') as csvfile:
numpy.loadtxt(csvfile,delimiter=",",skiprows=1)
with open('test.csv', 'rb') as csvfile:
numpy.loadtxt(csvfile,delimiter=",",skiprows=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment