New to Python and programming. I'm using a Mac Air w/ OS X Yosemite version 10.10.2.
I'm looking for a way to recursively find multiple subfolders, with the same name(e.g."Table"), without using a direct path(assuming I don't know what folders they might be in) and read the files within them using regular expressions or Python. Thank you in advance!
import sys
import os, re, sys
import codecs
import glob
files = glob.glob( '*/Table/.*Records.sql' )
with open( 'AllTables1.2.sql', 'w' ) as result:
for file_ in files:
print file_
if len(file_) == 0: continue
for line in open( file_, 'r' ):
line = re.sub(r'[\[\]]', '', line)
line = re.sub(r'--.*', '', line)
line = re.sub('NVARCHAR', 'VARCHAR', line)
line = re.sub(r'IDENTITY', 'AUTO_INCREMENT', line)
line = re.sub(r'DEFAULT\D* +','', line)
line = re.sub(r'\W(1, 1\W)', ' ', line)
result.write( line.decode("utf-8-sig"))
result.close()