I have a point shapefile with one field, a unique id called reg_no. I have a csv file with a reg_no column and other fields. I want to create a Feature Service in AGOL with the point geometry as a Feature Layer and the csv file as a Table. The goal is to do this purely with the ArcGIS API for Python. I do not want to use ArcMap/Pro or arcpy. I can add the shapefile and csv separately to AGOL and create separate Feature Services, but cannot get them in the same Feature Service. Once in the same Feature Service I will create a relationship between the Feature Layer and the Table so when you click on a point in a webmap you can access the Table data by selecting Show Related Records option in the popup.
I have tried adding the shapefile and the csv file to a zipped folder, adding to AGOL and publishing, as shown below, but this simply adds the shapefile as a point layer in the Feature Service. When looking at the contents I can see the shapefile item has been added from the zipped folder but nothing happens the csv file.
from arcgis import GIS
agol = GIS("home")
niah_zip = r"C:\Users\*****\Documents\Training\Data\NIAH.zip"
niah_agol = agol.content.add({}, niah_zip)
niah_fs = niah_agol.publish()