March 08, 2025

CSV's (All in folder) to Spreadsheet

CSV's (All in folder) to Spreadsheet

Below is the second sets of code using pyScripts/Python that helps transfer data from all CSV files in a folder to a single spreadsheet, with each CSV file being placed into a separate sheet.

The output of this code is same but I used earlier using pandas however I am here using pyspark to get same output.


The reason for performing this task is that, in most cases, we need to import Excel files as datasets for use in reporting or dashboard tools. If we import each CSV file individually, we may need to establish multiple connections. Additionally, relationships (ER) often don’t support interconnections between these multiple datasets. By using this script, we streamline the process by first converting the data types and then exporting the data into a single spreadsheet with multiple sheets, making it easier to work with the data in one unified format.

The Script

No comments:

Post a Comment