FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythoncde/countrows.py at master · ahertlcode/pythoncde · GitHub
ahertlcode
/
pythoncde
Public
Notifications
You must be signed in to change notification settings
Fork
5
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythoncde
/
countrows.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
22 lines (20 loc) · 926 Bytes
Breadcrumbs
pythoncde
/
countrows.py
Copy path
File metadata and controls
22 lines (20 loc) · 926 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import
os
import
pandas
as
pd
def
count_rows_in_directory
(
directory_path
):
total_rows
=
0
for
root
,
_
,
files
in
os
.
walk
(
directory_path
):
for
file
in
files
:
if
file
.
endswith
((
".xlsx"
,
".xls"
)):
# Check for Excel files
file_path
=
os
.
path
.
join
(
root
,
file
)
try
:
excel_file
=
pd
.
ExcelFile
(
file_path
)
# Load the Excel file
for
sheet
in
excel_file
.
sheet_names
:
sheet_data
=
excel_file
.
parse
(
sheet
)
# Read the sheet
total_rows
+=
sheet_data
.
shape
[
0
]
# Add the row count
except
Exception
as
e
:
print
(
f"Error processing
{
file_path
}
:
{
e
}
"
)
return
total_rows
# Replace with the path to your directory
directory_path
=
"EXAM_SCORE"
total_rows
=
count_rows_in_directory
(
directory_path
)
print
(
f"Total number of rows in all sheets:
{
total_rows
}
"
)
Back
|
FazBrowse Home
|
New Git URL