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.
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.
— 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:
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.
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
dtype=str) or pre-format in Excel after write. ssconvert or a streaming approach may use less memory than pandas. sep=... and encoding=... to read_csv, or pre-convert the files.References: RFC 4180 (CSV spec), pandas.to_excel docs, ssconvert manual.
So CSV with more than one tab? No. (plenty on the web like
https://stackoverflow.com/questions/9131744/is-it-possible-to-create-csv-file-with-multiple-tabs-in-command-prompt )
Most likely need to write some code using https://sourceforge.net/projects/xlslib/?source=directory
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.