Created
October 25, 2016 13:56
-
-
Save AndersonFirmino/4e7e8f3cb4dd95f9504c9082289e6e14 to your computer and use it in GitHub Desktop.
Script para merge de files sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
######################################################### | |
# Script para pegar varios arquivos sql em um diretorio | |
# e mesclar todos em um unico arquivo. | |
# by: Anderson Firmino (coderpy) <[email protected]> | |
# by: Gustavo Rodrigo (hpix) <[email protected]> | |
######################################################### | |
import os | |
def procedimento(path): | |
final_file = "" | |
for fn in os.listdir(path): | |
fn = path + fn | |
with open(fn, 'r') as f: | |
final_file += f.read() | |
with open('final.sql', 'w') as f: | |
f.write(final_file) | |
if __name__ == '__main__': | |
directory = os.path.dirname(os.path.abspath(__file__)) | |
directory += "/directory/" | |
procedimento(directory) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment