Python 3x, arcpy and all of its necessary modules should have already been installed on the machine when you installed ArcGIS Pro. You can check this by launching ArcGIS Pro, go to settings then to python and you can see the installed packages and also the path to the python environment.
To download an item from ArcGIS Online you will need to use the ArcGIS API for python. Essentially all you do is create a GIS connection (To ArcGIS Online):
arcgis.gis module — arcgis 1.7.0 documentation
Then you will get the service item by using content.get and the item ID:
arcgis.gis module — arcgis 1.7.0 documentation
Then you will export the item to an excel compatible format like CSV or xls by using .export:
arcgis.gis module — arcgis 1.7.0 documentation
Next you will download the exported item:
arcgis.gis module — arcgis 1.7.0 documentation
Then you can use XlsXWriter or CSV module to edit and change things around to how you want it.
Below is an example on how to export from ArcGIS Online. I didn't add in any code for the editing of the excel.
import arcgis
agoLogin = arcgis.GIS(url="URL to your ArcGIS Portal use none if to ArcGIS Online",
username="Your User Name",
password="Your Password")
itemToDownload = agolLogin.content.get("The Item ID")
exportLoc = r"The path where you want the file to download to"
itemExportName = "The Name of the Exported Item"
farmParcelLayer.export(title="Title / Name of the export. This will show up in ArcGIS Online",
export_format="Excel",
parameters=None,
wait=True)
searchForExportedItem = agolLogin.content.search(query=itemExportName)
exportedItemID = searchForExportedItem[0].id
getTheExportedItem = agolLogin.content.get(exportedItemID)
getTheExportedItem.download(save_path=exportLoc)