Learn how to Convert TXT File to CSV in Python
Created
October 11, 2025 04:40
-
-
Save aspose-com-gists/4af150b623f1b55ed757375a029df798 to your computer and use it in GitHub Desktop.
Convert TXT File to CSV in 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
from aspose.cells import Workbook, TxtLoadOptions, SaveFormat | |
# Step 1: Define load options with tab delimiter | |
load_options = TxtLoadOptions() | |
load_options.separator = '\t' # Tab-delimited text | |
# Step 2: Load the TXT file | |
workbook = Workbook("tab_delimited.txt", load_options) | |
# Step 3: Save as CSV file | |
workbook.save("converted.csv", SaveFormat.CSV) |
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
from aspose.cells import Workbook, SaveFormat | |
# Step 1: Load the TXT file | |
workbook = Workbook("sample_data.txt") | |
# Step 2: Save as CSV file | |
workbook.save("output.csv", SaveFormat.CSV) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment