Created
July 6, 2023 17:43
-
-
Save patent-ed/6d1d7a9419cdac0bc1982099fca98249 to your computer and use it in GitHub Desktop.
macos script that collects data from https://jamf-patch.jamfcloud.com/v1/software/ and output to UTF-8 csv and saves to /users shared folder on macOS, named by timestamp
This file contains 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 requests | |
import pandas as pd | |
import os | |
import datetime | |
# Get data from website | |
response = requests.get('https://jamf-patch.jamfcloud.com/v1/software/') | |
data = response.json() | |
# Convert data to pandas DataFrame | |
df = pd.DataFrame(data) | |
# Get timestamp | |
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") | |
# Get Users Shared directory path | |
shared_dir = os.path.expanduser('/Users/Shared') | |
# Ensure the shared directory exists | |
os.makedirs(shared_dir, exist_ok=True) | |
# Name of the output file | |
file_name = os.path.join(shared_dir, f'output_{timestamp}.csv') | |
# Save DataFrame to CSV file in Users Shared folder | |
df.to_csv(file_name, index=False, encoding='utf-8') | |
print(f"Data saved to {file_name}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run in terminal: python3 ./savesoftware.py