Guest User

Untitled

a guest
Sep 18th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. conn = pymysql.connect(host='localhost',
  2. user='test_user',
  3. password='',
  4. db='%s'%country_index)
  5. cur = conn.cursor()
  6.  
  7. path = r'C:UsersRobinDesktopusa_indicator'
  8. filenames = glob.glob(path + '/*.csv')
  9. dfs = []
  10. for files in filenames:
  11. f = open(files)
  12. fString = f.read()
  13. fName = files[37:2]
  14.  
  15. for lines in fString.split('n'):
  16.  
  17. dfs.append(lines.split(','))
  18.  
  19. DATE = dfs[0][1]; REALTIME_START = dfs[0][2]; VALUE = dfs[0][3]
  20.  
  21.  
  22.  
  23. queryCreateTable = """CREATE TABLE '%s'(
  24. {} int,
  25. {} int,
  26. {} int
  27. )"""%fName.format(DATE, REALTIME_START, VALUE)
  28.  
  29. cur.execute(queryCreateTable)
  30.  
  31. conn.close()
Add Comment
Please, Sign In to add comment