Hi,
I was wondering if anybody could help me with this. I have two .csv file that I need to put it in an excel file in two different tabs using Shell Script.

Thanks in advance.

Dani AI

Generated

is correct that a plain .csv is a single, line-oriented text table; it cannot carry multiple worksheet tabs. The usual approach is to create a proper Excel workbook (XLSX/XLS) and put each CSV into its own sheet. (CSV format: see RFC 4180.)

Two practical, shell-friendly options that work reliably:

  1. Use a tiny Python script (pandas) called from your shell — easy to control sheet names and encoding. Example script (save as csvs_to_xlsx.py and run python3 csvs_to_xlsx.py):
#!/usr/bin/env python3
import pandas as pd

with pd.ExcelWriter('combined.xlsx', engine='openpyxl') as writer:
    pd.read_csv('file1.csv', encoding='utf-8').to_excel(writer, sheet_name='First', index=False)
    pd.read_csv('file2.csv', encoding='utf-8').to_excel(writer, sheet_name='Second', index=False)

Install prerequisites with pip install pandas openpyxl. Pandas gives explicit control over sheet names, separators, encodings and types.

  1. Use the command-line converter ssconvert (part of Gnumeric) to merge CSV files into one workbook in one command:
ssconvert --merge-to combined.xlsx file1.csv file2.csv

-M is the short option for --merge-to. This is a very quick no-code route if the CSVs are already in the exact form you want.

Notes and troubleshooting

  • If values are being reinterpreted (dates, leading zeros), read them as strings in pandas (dtype=str) or pre-format in Excel after write.
  • For very large CSVs, ssconvert or a streaming approach may use less memory than pandas.
  • If your CSV uses non-standard delimiters or encodings, pass the correct sep=... and encoding=... to read_csv, or pre-convert the files.

References: RFC 4180 (CSV spec), pandas.to_excel docs, ssconvert manual.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.