Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. # coding=utf-8
  2. #########################################################
  3. # Script para pegar varios arquivos sql em um diretorio
  4. # e mesclar todos em um unico arquivo.
  5. # by: Anderson Firmino (coderpy) <anderson.araujoprog@gmail.com>
  6. # by: Gustavo Rodrigo (hpix) <rodrigogustavo_@hotmail.com>
  7. #########################################################
  8. import os
  9.  
  10.  
  11. def procedimento(path):
  12. final_file = ""
  13. for fn in os.listdir(path):
  14. fn = path + fn
  15. with open(fn, 'r') as f:
  16. final_file += f.read()
  17.  
  18. with open('final.sql', 'w') as f:
  19. f.write(final_file)
  20.  
  21. if __name__ == '__main__':
  22. directory = os.path.dirname(os.path.abspath(__file__))
  23. directory += "/directory/"
  24. procedimento(directory)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement