Created
February 10, 2025 12:25
-
-
Save nikdudaev/6b600236826ae7d90705c98bb77b1aca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import argparse | |
def excel_to_csv(excel_file, output_csv): | |
# Load the Excel file | |
xls = pd.ExcelFile(excel_file) | |
# Read all sheets into a list of DataFrames | |
df_list = [xls.parse(sheet_name) for sheet_name in xls.sheet_names] | |
# Concatenate all sheets into a single DataFrame | |
combined_df = pd.concat(df_list, ignore_index=True) | |
# Save to CSV | |
combined_df.to_csv(output_csv, index=False) | |
print(f"All sheets from {excel_file} have been merged and saved to {output_csv}") | |
def main(): | |
parser = argparse.ArgumentParser(description="Merge all sheets of an Excel file into a single CSV file.") | |
parser.add_argument("input", help="Path to the input Excel file") | |
parser.add_argument("output", help="Path to the output CSV file") | |
args = parser.parse_args() | |
excel_to_csv(args.input, args.output) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment