Skip to content

ironcastlesystems/CSV_Split

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Š CSV/XLSX Splitter Script

This PowerShell script allows you to split large .csv files into smaller, manageable chunks based on either file size (for CSV output) or row count (for Excel .xlsx output). It’s designed for speed, flexibility, and usabilityβ€”ideal for data processing, archiving, or sharing.

πŸš€ Features

  • Console-only interaction (no GUI prompts)
  • Select any folder containing .csv files
  • Choose output format: .csv or .xlsx
  • Streamed writing for CSV (fast and memory-efficient)
  • Excel export via ImportExcel
  • Configurable chunk size (MB) or row limit
  • Optional header inclusion in each chunk
  • Timestamped output folder for easy organization
  • Progress tracking and summary display

πŸ›  Requirements

  • Windows PowerShell 5.1 or PowerShell Core
  • ImportExcel module (only required for .xlsx output)

To install ImportExcel:

Install-Module -Name ImportExcel -Scope CurrentUser

πŸ“ Output Structure

  • Output files are saved in a subfolder named like:
    filename_split_YYYYMMDD_HHMMSS
  • Files are named:
    filename_chunk_1.csv, filename_chunk_2.xlsx, etc.

βš™οΈ Usage

Run the script in PowerShell and follow the prompts:

PS> .\Split-Csv.ps1
'''

Example interaction:

Enter folder path containing CSV files (press Enter for Desktop): C:\Data
Enter the number of the file to split: 1
Do you want the output files in Excel XLSX format? (Y/N): Y
Enter max number of rows per Excel file (default is 50000): 25000
Include headers in each chunk? (Y/N, default is Y): Y
βœ… Splitting complete!
Chunks created: 12
Saved to: C:\Data\sales_data_split_20250910_1045

πŸ“‹ Parameters

Parameter Description Default
chunkSizeMB Max size per CSV chunk (in megabytes) 100
maxRowsPerChunk Max rows per Excel chunk 50000
includeHeaders Include header row in each chunk Yes

πŸ“œ License

MIT License

πŸ™Œ Credits

Created by David Reynolds
Excel export powered by ImportExcel

About

Split large CSV files into smaller one or xlsx file format with options.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published