Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def convert_recursive(path, sheetid, outfile, kwargs):
for name in os.listdir(path):
fullpath = os.path.join(path, name)
if os.path.isdir(fullpath):
convert_recursive(fullpath, sheetid, outfile, kwargs)
else:
outfilepath = outfile
if len(outfilepath) == 0 and fullpath.lower().endswith(".xlsx"):
outfilepath = fullpath[:-4] + 'csv'
print("Converting %s to %s" % (fullpath, outfilepath))
try:
Xlsx2csv(fullpath, **kwargs).convert(outfilepath, sheetid)
except zipfile.BadZipfile:
print("File %s is not a zip file" % fullpath)