Skip to content

Instantly share code, notes, and snippets.

@patent-ed
Created July 6, 2023 17:43
Show Gist options
  • Save patent-ed/6d1d7a9419cdac0bc1982099fca98249 to your computer and use it in GitHub Desktop.
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
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}")
@patent-ed
Copy link
Author

run in terminal: python3 ./savesoftware.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment