daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. with open('myFile', 'r') as csvfile:
  2. theReader = csv.reader(csvfile)
  3. for row in theReader:
  4.      # my logic here
  5.    
  6. with open('myFile', 'rb') as csvfile:
  7.      reader = csv.reader(filter_line(line) for line in csvfile)
  8.      for row in reader:
  9.          # my logic here
  10.    
  11. from contextlib import contextmanager
  12.  
  13. @contextmanager
  14. def csv_factory(filename, mode="r"):
  15.     # setup here
  16.     fileobj = open(filename, mode)
  17.     reader = mycsv.reader(fileobj)
  18.     try:
  19.         yield reader # return value for usage in with
  20.     finally:
  21.         fileobj.close() # clean up here
  22.  
  23.  
  24. with csv_factory("myFile") as csvfile:
  25.     for line in csvfile:
  26.         print(line)
  27.    
  28. for line in sys.stdin.readlines():  
  29.     # some extra code goes here
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top