Merge Columns

Merge two columns from a CSV file into a single combined column

Accepted format: CSV (Maximum size: 500 MB)
First column index to merge.
Second column index to merge.

Merge Columns

Function

Merging columns combines data from two separate columns into a single column. This is useful for creating composite identifiers, labels, keys, and consolidated fields.


Input Format

  • CSV file containing tabular data.
  • Two column indices specifying columns to merge.

Output Format

  • CSV file containing merged column values.
  • Original data structure preserved.

Applications

  • Combine first name and last name fields.
  • Create genomic identifiers.
  • Generate composite keys for database joins.
  • Prepare labels for plots and reports.
  • Reformat data for downstream analysis tools.

Example

Input:

Gene,Transcript
BRCA1,NM_007294
TP53,NM_000546

Merged:

BRCA1_NM_007294
TP53_NM_000546

Example Using AWK

awk -F',' 'BEGIN{OFS=","}
{
    print $0, $1"_"$2
}' input.csv > merged.csv

Example Using Python

import pandas as pd

df = pd.read_csv("input.csv")

df["merged"] = (
    df.iloc[:,0].astype(str)
    + "_"
    + df.iloc[:,1].astype(str)
)

df.to_csv("merged.csv", index=False)

Suggested Reading


Important Notes

  • Input file must be CSV format.
  • Column numbering starts from 1.
  • Selected columns must exist in the file.
  • Large files may require additional processing time.
  • Merged values are typically joined using an underscore separator.