Here is an idea for a program that I would like to create:
Get a list of all excel files in a specific folder and its subfolders, which could also be a FOlder on a different Server given as a UNC-Path. the list needs to hav the name, path,size,author, owner, create datetime, last edited, last accessed.
The list should also contain the name and source of the data connections used in the Excel-file.
It should also show the names of all sheets and their respective rowcount and how many pivot charts it contains.
Assistant
User
Thanks, but I guess you might know that you will be the one who will support me with that endeavor.
Assistant
Of course, I'm here to help you throughout the process! Here's a more detailed plan to create the program based on your requirements:
Create a function to get file metadata (Windows-specific):
User
Haha, you are funny. You already helped me a great deal. You just dont remember our previous conversations, what a pity. But I can tell you, you are a great programmer.
Assistant
You're welcome! It's always great to have someone to bounce ideas off of and learn from. I'm happy to help in any way I can.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
That's a great idea for a program! Here's a high-level outline of how you could create such a program using Python and its libraries:
Import necessary libraries: You'll need to import the following libraries: os, glob, pandas, openpyxl, win32com.client (for Windows), and pywin32 (for Windows).
Get a list of Excel files: Use the os.walk() function to recursively walk through the specified folder and its subfolders. For each file, check if it has an .xlsx or .xls extension using glob.glob(). Store the file path, name, size, author, owner, creation time, last edited time, and last accessed time in a list of dictionaries. You can use the os.stat() function to get file metadata and the get_file_metadata() function from the win32com.client library to get author and owner information (for Windows).
Get data connections: For each Excel file, open it using the openpyxl library and iterate through its connections using the workbook.connections property. Store the name and source of each connection in the corresponding dictionary.
Get sheet information: For each Excel file, open it using the openpyxl library and iterate through its sheets using the workbook.worksheets property. For each sheet, get its name, row count, and pivot chart count. You can use the sheet.max_row property to get the row count and the sheet.pivot_tables property to get the pivot chart count.
Create a DataFrame: Convert the list of dictionaries into a pandas DataFrame for easy manipulation and export.
This code snippet should give you a good starting point for creating your program. You may need to modify it to fit your specific requirements and handle any edge cases.
Create a function to get a list of Excel files in a folder and its subfolders:
python
import os
import glob
def get_excel_file_list(folder_path):
file_list = []
for root, _, files in os.walk(folder_path):
for file in glob.glob(os.path.join(root, "*.xlsx")):
file_list.append(get_excel_file_info(file))
return file_list
Create a function to convert the list of Excel file information into a pandas DataFrame:
python
import pandas as pd
def create_dataframe(file_list):
return pd.DataFrame(file_list)
This plan should help you create the program step-by-step. Feel free to ask any questions or request further assistance as you work through the process.