python script to copy datasource from one location to another

34 Views Asked by At

i am trying to write a code to copy a datasource on Tableau server from one project to another project. I have written a python script and working fine in my local. Now i need to call the same code in Tableau prep and run on the Tableau server.

Please guide me through is there any way i can achieve this.

type himport pandas as pd  
import shutil


def testing_names(self):
# Specify the source Hyper file and its location
source_hyper_file = r'C:\Users\PA111898\Downloads\Python\Entitlements_All.tdsx'

# Specify the destination folder and the new name for the Hyper file
destination_folder = r'C:\Users\PA111898\Downloads'
new_hyper_file_name = 'Entitlements_Final_Test.tdsx'

# Construct the full path to the destination Hyper file
destination_hyper_file = os.path.join(destination_folder, new_hyper_file_name)

# Copy the source Hyper file to the destination with the new name
shutil.copyfile(source_hyper_file, destination_hyper_file)

# Create DataFrame  
df = pd.DataFrame(data)  
return dfere
0

There are 0 best solutions below