Skip to content

Commit b562586

Browse files
Excel_file_merger is Added
1 parent 6803612 commit b562586

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from openpyxl import load_workbook
2+
from openpyxl import Workbook
3+
import os
4+
5+
6+
# Read data from active worksheet and return it as a list
7+
def reader(file):
8+
global path
9+
abs_file = os.path.join(path, file)
10+
wb_sheet = load_workbook(abs_file).active
11+
rows = []
12+
# min_row is set to 2, ignore the first row which contains headers
13+
for row in wb_sheet.iter_rows(min_row=2):
14+
row_data = []
15+
for cell in row:
16+
row_data.append(cell.value)
17+
rows.append(row_data)
18+
return rows
19+
20+
21+
# You can replace these with your own headers for the table
22+
headers = ['Nume', 'Prenume', 'Titlu', 'Editura', 'Cota', 'Pret', 'An']
23+
# Unified excel name
24+
workbook_name = input('Unified Workbook name ')
25+
book = Workbook()
26+
sheet = book.active
27+
# Specify path
28+
path = input('Path: ')
29+
# Get all files from folder
30+
files = os.listdir(path)
31+
for file in files:
32+
rows = reader(file)
33+
for row in rows:
34+
sheet.append(row)
35+
book.save(filename=workbook_name)

Excel_File_Merger/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
**Excel_file_merger**
2+
3+
4+
5+
**How to Use:**
6+
This Script is an Excel_file_merger before that we need to import openpyxl ($pip install openpyxl) Then just we need to run Excel_file_merger.py simple and easy to use.
7+
8+
9+
**conclusion:**
10+
11+
This Just a Script That we can allow to Merge files from the terminal itself!
12+
13+
#### By [Kalivarapubindusree]()

0 commit comments

Comments
 (0)