-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDATA-EXTRACTION.py
36 lines (28 loc) · 1.01 KB
/
DATA-EXTRACTION.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
# Get the current working directory
current_directory = os.getcwd()
print(current_directory)
# Create an empty list called files_info to store your dictionaries
files_info = []
def list_files_in_directory(directory='.'):
# Create an empty list to store dictionaries
files_info = []
# Loop through files in the directory
for file in os.listdir(directory):
file_path = os.path.join(directory, file)
# Check if it's a file and add its info to the list
if os.path.isfile(file_path):
file_info = {
'name': file,
'size': os.path.getsize(file_path),
'path': file_path
}
files_info.append(file_info)
return files_info
# Create the list of files in the directory
file_list = list_files_in_directory()
# Print each file's details in a vertical list format
for file in file_list:
print("Name:", file['name'])
print("Size:", file['size'])
print("Path:", file['path'])