Saturday, June 13, 2026

How to consolidate CSV files

If there are a number of CSV files that have the same data structure, they can be consolidated using a CMD command. If all CSV files have identical headers, combining them into a single CSV file is very easy.

Steps

  1. Put all your CSV files into one folder.
  2. Open cmd.exe in that folder:
    • Open the folder in File Explorer.
    • Click the address bar.
    • Type cmd and press Enter.
    • A Command Prompt window will open in that folder.
  3. Type the following command and press Enter:

copy *.csv Combined.csv

This command merges all CSV files in the current folder into a file named Combined.csv.

Important Note

If every CSV file contains the same header row, the above command will also copy the headers repeatedly. To keep only one header row:

  • Create the combined file using the first CSV file.
  • Append the remaining files without headers, or remove duplicate header rows afterward using Excel, Power Query, or a script.

Example:

Files:

Sales1.csv

Sales2.csv

Sales3.csv

Command:

copy *.csv AllSales.csv

Result:

AllSales.csv

You can open the consolidated CSV file in Excel or any text editor to verify the merged data.

C# How to find factorial of 999

In C# interview, you may be asked How To find the factorial of 999 in C#, you cannot use int, long, or even decimal because factorial values grow extremely fast.

Use BigInteger from System.Numerics.

Example:

using System;
using System.Numerics;

class Program
{
    static BigInteger Factorial(int n)
    {
        BigInteger result = 1;

        for (int i = 2; i <= n; i++)
        {
            result *= i;
        }

        return result;
    }

    static void Main()
    {
        int number = 999;

        BigInteger factorial = Factorial(number);

        Console.WriteLine(factorial);
    }
}

Output

This prints the exact value of 999! (a huge number).

Why BigInteger?

Look at the approximate limits of different data types:

  • int → up to ~2 billion → only enough for 12!
  • long → up to ~9 quintillion → only enough for 20!
  • BigInteger → arbitrary precision (limited mainly by memory)

Alternative Solution: Short version using LINQ

using System;
using System.Linq;
using System.Numerics;

BigInteger factorial =
    Enumerable.Range(1, 999)
              .Aggregate(BigInteger.One, (a, b) => a * b);

Console.WriteLine(factorial);

Count digits of 999!

Console.WriteLine(factorial.ToString().Length);

999! contains 2,565 digits.

Hot Topics