Last active
April 23, 2026 08:18
-
-
Save aspose-com-gists/0a5cd10d0f54367efaedc7ae1876cae0 to your computer and use it in GitHub Desktop.
Convert XLSX to CSV using Python
This file contains hidden or 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
| import aspose.cells | |
| from aspose.cells import Workbook, SaveFormat | |
| def convert_xlsx_to_csv(input_file: str, output_file: str): | |
| try: | |
| # Load the XLSX workbook | |
| workbook = Workbook(input_file) | |
| # Save the first worksheet as CSV | |
| workbook.save(output_file, SaveFormat.CSV) | |
| print(f"Conversion successful: {output_file}") | |
| except Exception as e: | |
| print(f"Error during conversion: {e}") | |
| if __name__ == "__main__": | |
| input_path = "Data/sample.xlsx" | |
| output_path = "output/sample.csv" | |
| convert_xlsx_to_csv(input_path, output_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment