Hi,
I was trying to replace the csv file in the cas server using python-swat interface. However, I encounter error with "Global Table cannot be replaced" when I run it.
Below is the code I used to upload the data. Anyone know the reason behind it? Thank you
conn.upload('abc.csv',casout=dict(name='trialupload2',caslib='public',promote = 'true',replace = 'true'))
TRIALUPLOAD2 table is in my cas server, and when I try to replace it, it resulted in the above error.
Try dropping the table first using the dropTable action
ERROR: Global tables cannot be replaced.
This is a valid error because "promote" and "replace" cannot be used together.
Hi @alexal,
If that is the case, then may I know is there any workaround for this? because I wish to overwrite the existing data in the CAS server. And if I set the promote to false, the data uploaded won't be visible to me anymore.
Upload the data to your session scope, then promote to the global scope (in a separate action).
May I know the proper way of promoting to global scope? Now that with
conn.read_csv('abc.csv',casout=dict(name='trialupload123',caslib='public',replace ='true'))
thiis command I am able to upload to the session scope.
But using when trying to promote to global scope using the below command it fails.
conn.read_csv('abc.csv',casout=dict(name='trialupload123',caslib='public',promote = 'true'))
Something like that:
load_csv = conn.read_csv('https://raw.githubusercontent.com/sassoftware/sas-viya-programming/master/data/cars.csv',casout=dict(name='CARS',caslib='CASUSER',replace ='true'))
promote_csv = conn.promote(load_csv,target='NEW_NAME_FOR_CARS_TABLE')
Thanks for the code. However, there is still one problem here. The error exists because the target table of the promotion already exists. Means that I couldn't overwrite the table of the same name in the CAS server.
ERROR: The target table trialupload432 of the promotion already exists. Please specify a different name.
thanks for the solution. However, the problem is that the table name in the global scope will be different everytime I upload the data. And in the SAS Studio I will have to access data from different tables every time.
Try dropping the table first using the dropTable action
Thanks. That will do the trick
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.