filmov
tv
Python: Split Each Excel Sheet Into Separate Files (fast & easy)
![preview_player](https://i.ytimg.com/vi/DyfLlbbPNsc/maxresdefault.jpg)
ะะพะบะฐะทะฐัั ะพะฟะธัะฐะฝะธะต
๐๐๐ฆ๐๐ฅ๐๐ฃ๐ง๐๐ข๐ก
โโโโโโโโโโโโโโโโโโโโโโโโโโ
This video will show you how to split each worksheet in Excel into a separate Excel file/workbook using Python instead of VBA. In particular, we will be using the xlwings library.
Remark: In the video, I have used the os dependent '.api' method to copy sheets.
Since xlwings version 0.22 the '.copy()' has been implemented.
Additionally, xlwings.App() can now be used as context manager in xlwings v0.24.3:
This will make sure that there are no zombie processes left over on Windows, even if you use a hidden instance and your code fails.
It is therefore recommended to use it whenever you can. Therefore I have adjusted the code as follows:
๐ฉโ๐ป ๐ฃ๐๐๐ต๐ผ๐ป ๐๐ผ๐ฑ๐ฒ:
from pathlib import Path
import xlwings as xw # pip install xlwings
EXCEL_FILE = Path(__file__).parent / 'YOUR_EXCEL_FILE.xlsx'
OUTPUT_DIR = Path(__file__).parent / 'Output'
# Create Output directory
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
with xw.App(visible=False) as app:
๐ง๐ข๐ข๐๐ฆ ๐๐ก๐ ๐ฅ๐๐ฆ๐ข๐จ๐ฅ๐๐๐ฆ
โโโโโโโโโโโโโโโโโโโโโโโโโโ
๐๐ข๐ก๐ก๐๐๐ง ๐ช๐๐ง๐ ๐ ๐
โโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐๐๐ ๐บ๐ฒ ๐ฎ ๐ฐ๐ผ๐ณ๐ณ๐ฒ๐ฒ?
ะะพะผะผะตะฝัะฐัะธะธ