Split a Single CSV File into Multiple Files Using the Split Command - Bash
Working with huge CSV files? Need to split them for easier management and analysis? Look no further - I will show you how to split large CSV files using the split
command in Bash. This quick guide will help you split your data like a pro!
Step 1: Open Your Terminal
To begin splitting your CSV files, open your terminal. You can use split
in Bash on Linux, macOS, or Windows with WSL (Windows Subsystem for Linux).
Step 2: Navigate to the File’s Directory
Navigate to the directory where your CSV file is located using the cd
command:
cd /path/to/your/csv/directory
Step 3: Splitting the CSV File
Use the split
command to divide your CSV file by specifying the number of lines in each new file:
split -l 1000 large_data.csv smaller_data_
This command will split large_data.csv
into smaller files, each containing 1000 lines. The new files will be named smaller_data_aa
, smaller_data_ab
, smaller_data_ac
, and so on.
Step 4: Verify the Split
To confirm that the split was successful, list the files in your directory:
ls
Got a project in mind? Send me a quick message, and I'll get back to you within 24 hours!.
Recent Posts
- Disabling Payment Methods in WooCommerce Based on Conditions
- How to Update Product Quantity in WooCommerce Using Custom Code
- Dynamically Generating a Table of Contents in WordPress
- Direct Checkout in WooCommerce - Add Product to Cart from Checkout Page & Skip Shop, Product, and Cart Pages
- Understanding the Impact of git reset --hard Command
Your Questions / Comments
If you found this article interesting, found errors, or just want to discuss about it, please get in touch.