Server250exe

tutorial_csv_driver.py

Mar 27th, 2022
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. from DatasourceDriverTemplate import Driver as TemplateDriver
  2. import csv
  3.  
  4. class Driver(TemplateDriver):
  5.     def __init__(self, args):
  6.         self.data = dict()
  7.  
  8.         if len(args)>0:
  9.            
  10.             csv_file_location = args[0]
  11.  
  12.             with open(csv_file_location) as csv_file:
  13.                 csv_reader = csv.reader(csv_file)
  14.                 for row in csv_reader:
  15.                     self.data[row[0]] = [row[1], row[2]]
  16.  
  17.     def get(self, args):
  18.         return self.data[args[0]]
Advertisement
Add Comment
Please, Sign In to add comment