@Graipher already shows you how your code can look like if you follow PEP8. But since you've explicetely mentioned the Style Guide, let's have a look closer look at some parts.
Your import look like this at the moment:
import openpyxl, csv, os, re, shutil
Now listen and repeat after PEP8 - Imports:
- Imports should usually be on separate lines.
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and
Imports should be grouped in the following order:
- Standard library imports.
- Related third party imports.
- Local application/library specific imports.
You should put a blank line between each group of imports.
Strictly following the Style Guide would lead to something like:
I think it should be quite obvious to see how this would be applied to @Graipher's answer.
"""docstrings""" have not yet found their way into your code, but again @Graipher presents a good execution of their use in his answer. They are also introduced in the Style Guide in section Documentation Strings, and even more detailed in PEP257. Using the syntax as shown by @Graipher and the Style Guide has the nice benefit that Python's built-in
help(...) as well as basically all Python IDEs will be able to find it easily. I highly recommend to get used to them, once you're at a point where you work on a program that spreads out over several files, these nifty little lines of documentation (together with an IDE that is able to read them) will likely help you to maintain your mental health.
Bonus: Automate the Boring Stuff
Maintaining a consistent, PEP8-compliant style can become tedious, especially on a larger scale. Luckily, there are a lot of good tools to automate the boring stuff for you. First, there are tools like pylint, pycodestyle, and flake8 that can perform style checking on your code. But you can go even further! At the moment, these tools leave fixing the "issues" they find in your code to you. Enter tools like black or yapf, just to name two of them. They can auto-format your to follow style guidelines, e.g. PEP8. If you use a feature-rich code editor like Visual Studio Code (or Atom - not 100% sure here), they can even perform the task on-the-fly while you're writing code. All the tools mentioned above are configurable so you don't have to have to figth windmills if they work against a pet peeve of yours. But often the default configuration will work quite reasonable.