🗂️ Group and Convert CSV Files to Excel (Python)
This script will:
-
Group CSV files based on their naming convention (by prefix and category).
-
Read each CSV file, which is delimited by
|(pipe character). -
Combine data from each group into a single Excel file with separate sheets for each category.
-
Save the final output as Excel files organized by their prefix.
🔑 Key Steps:
-
File Grouping: It identifies and groups CSV files by their prefix (e.g., "Area", "Basemap").
-
Merging Data: All CSVs in each group are combined into one Excel sheet for that category.
-
Excel Output: The final grouped data is written into Excel files, with each category in a separate sheet.
🧑💻 Python Script:
📋 Key Features:
-
Grouping: Organizes CSV files based on the prefix (e.g., "Area", "Basemap").
-
Excel Sheets: Each category within a prefix gets its own Excel sheet.
-
Error Handling: It gracefully handles errors when reading malformed CSVs or reading issues with specific files.
-
Efficient Output: All grouped data is consolidated into a clean, organized Excel workbook for each prefix.
✅ Conclusion:
This solution provides an efficient method for converting and consolidating multiple CSV files into structured Excel workbooks. It's perfect for organizing large datasets, especially when dealing with a variety of related CSV files that need to be grouped and categorized.