Sarathlal N

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

Looking for a developer who loves your business? I'm available for remote and freelance work. Let's connect.

Recent Posts

  1. How to Update Product Quantity in WooCommerce Using Custom Code
  2. Dynamically Generating a Table of Contents in WordPress
  3. Direct Checkout in WooCommerce - Add Product to Cart from Checkout Page & Skip Shop, Product, and Cart Pages
  4. Understanding the Impact of git reset --hard Command
  5. How to Move Uncommitted Changes to a New Branch in Git

Your Questions / Comments

If you found this article interesting, found errors, or just want to discuss about it, please get in touch.