Skip to main content

#The0 personne en discute

I am using "Tableau Server Client(Python) and Python 3.9" and trying to download the data source and publish to a server.

 

when i try to parse through all available data sources i am able to download the data source file, however, when i try to find the data source associated with a workbook i am unable to download it. 

 

I am trying to download the data source associated with a workbook but unable to do so.

 

here is the relevant code

 

```

 

with server.auth.sign_in(tableau_auth):

  """

  for ds in TSC.Pager(server.datasources):

    if ds.project_name == "project_name":

      print(ds.id)

      fp = server.datasources.download(ds.id)

      print("\n downloaded the file to {0}", format(fp))   

  """

 

  #the above works

 

  for workbook in TSC.Pager(server.workbooks):

    if workbook.project_name == "project_name":

      server.workbooks.populate_connections(workbook)

      for con in workbook.connections:

        ds = server.datasources.get_by_id(con.datasource_id)

        server.datasources.download(ds.id) ⌗this does not work and give a 404 error

```

 

please check my comments inline where the i get 404 error when trying to download data source associated with a workbook

 

the datasource id seems to be different when checking server.datasources and server.workbooks. for example the below code produce this output

 

```

  for ds in TSC.Pager(server.datasources):

    if ds.project_name == "Test(Akshar)":

      print(ds.id)

 

  for workbook in TSC.Pager(server.workbooks):

    if workbook.project_name == "Test(Akshar)":

      server.workbooks.populate_connections(workbook)

      for con in workbook.connections:

        print(con.datasource_id)

 

```

 

produces this output

 

```

f648e7c4-d3e2-4ca9-8b65-59a42cc28a35

364fd4d8-ae62-4051-b59b-8ef3fdd624d7

3fdd7fcc-9052-474c-bf17-45636e2b1060

```

3 réponses
  1. 5 mai 2022, 15:39

    If it's embedded in the workbook, as a .twbx, I would guess is you can convert it to a .zip file, extract the file, and then you'll be able to pull the data source out of the data folder. I have no idea how to do that in Python, but hopefully, this helps you down the road a bit. -Mark

0/9000

🗞️ #The Trailblazer Tribune June 28, 2024 🗞️

 

Take the Trailblazer Community Experience Survey and download  ⬇️ this week's Trailblazer Tribune to register for the events, and access all links!🗞️ June 28, 2024 🗞️ Take the Trailblazer Community Experience Survey and download ⬇️ this week's Trailblazer Tribune to register for the events, and access all links!NEW CONTENT EVERY WEEK! Be sureNEW CONTENT EVERY WEEK! Be sure to read our content weekly in your inbox to learn about the latest news and upcoming events.

 

⭐ FEATURED EVENT: DREAMFORCE 2024 ON SAN FRANCISCO & SF+

 ******************************************************************************

Discover the latest innovations. Engage with product experts. Make a difference. And have a blast. It’s all happening at Dreamforce. Unlock $1,000 in savings with early bird passes!

 

🏖️ INNOVATE: SUMMER '24 RESOURCES

******************************************************************************

Download the PDF to access all the Summer '24 resources and join @* Release Readiness Trailblazers * to follow all the latest announcements about Salesforce releases.

 

🎓 LEARN 

******************************************************************************

👀 NEED TO KNOW

  • Meet My Service Journey
  • Mobile Publisher iOS and Android New Builds
  • Manage Email Notifications for Expiring Certificates
  • Learn how to Create a Data Cloud Segment

💪 RESOURCES TO HELP YOU GROW

Introducing Hyperforce | Expert Coaching Session

New Series: Innovate with Prompt Builder

 

Einstein

Get Started with Einstein Generative AI for Devs

 

Data Cloud

Build AI Models in Einstein Studio

New Video: Data Spaces

Blog: Full Stream Ahead

 

MuleSoft

New Content on Expanded AsyncAPI Support

 

And much MORE content! Check out the PDF file to find more goodies.

Download ⬇️ this week's Trailblazer Tribune to register for the events, and access all links!

 

Was this post useful? Click the like button if it helped you! 👍

2 commentaires
0/9000

Hello Everyone,

 

I am new to SFDC and the Marketing Ops role, so I'm hoping to seek some guidance on the following tasks I've been assigned. Here's is what the requestor is asking for:

 

1. Is it possible to generate a report listing the Job Title(s) that converted from an MQL to SQL for the specified campaigns?

2. Additionally, could we have a separate list of the Job Title(s) that converted (MQL to SQL) for these specific campaigns?

 

I have been provided with a campaign list. 

3 réponses
0/9000
0/9000

🗞️ #The Trailblazer Tribune February 3, 2023 🗞️

 

NEW CONTENT EVERY WEEK! On today's edition: TDX is one month away, New features for Slack huddles on Mobile, MuleSoft + Automation, Trailhead updates (new help portal & quest), and more.

 

Download file to get the links

🗞️ February 3, 2023 🗞️ NEW CONTENT EVERY WEEK! On today's edition: TDX is one month away, New features for Slack huddles on Mobile, MuleSoft + Automation, Trailhead updates (new help portal & quest)

⭐ FEATURED EVENT: TrailblazerDX ⭐

******************************************************************************

Mar 7-8 @ San Francisco and Salesforce+

200+ technical sessions, product demos, expert-led workshops, and hands-on learning. You can also expect 1,000+ certification opportunities!

Register now and Get the Admin’s Guide to TDX 2023

 

💜 INNOVATE: Spring '23 💜

 ******************************************************************************

Click on the recording of your interest below or access the full playlist here

 

Admin Preview | Developer Preview | Sales Cloud | Flow | Service Cloud | Field Service

Financial Services Cloud | Health Cloud | Experience Cloud | Commerce Cloud

CRM Analytics | MCAE (fka Pardot)

 

- Screen sharing in Slack Huddles on Mobile

- Learn MOAR & Discover Spring ‘23 Features 

 

Join @* Release Readiness Trailblazers * to follow all the latest announcements about Salesforce releases.

 

🎓 LEARN 🎓

 ******************************************************************************

- New! Solution Like an Integration Architect Quest

- How to Invoke a Flow from a Global Action

- Upcoming Commerce events - RSVP today

 

Interested in @* MuleSoft * + @Salesforce Flow Automation?

- MuleSoft Automation in the context of Salesforce

- MuleSoft RPA + Salesforce Flow Demo

- MuleSoft Classes Now on Trailhead Academy!

 

Latest Answers Leaders How-to's

- Display Campaigns on an Opportunity with Flow

 

Join the @* Answers Connect * group and check out the latest Answers Newsletter

 

🤝 CONNECT & GIVE BACK 🤝

 ******************************************************************************

- Feedback Wanted: The Salesforce Developer Survey

- Vote now! Education Summit 2023 Awards

- SF .Org Quick Snapshot of What's coming next

 

3 commentaires
0/9000

Hi Guys,

 

I have huge amount of csv files under different projects folder. What I want to do is to set up a project filter first, and then based on this project Python code will scan all the files under this folder. Then I can use this return file lists as another filter. After that, python will open specific csv files based on these two steps filter. The reason to do that is that I don't want to load all the data into tableau one time, it's huge amount of data as I mentioned.

 

I can easily write code in the Python Jupyter Notebook. But it's not easy to complete this in Tableau for me. Hopefully, I can get the idea from you guys. Thank you so much.

 

My code will be like this:

#Code to read all the files under a filtered project

⌗This code is okay in Jupyter notebook, but has error in the tableau, I cannot figure it out why it has error

script_str(

"

import os

Proj = _arg1 # Project filter

Folder = r"C:\Samples\" + Proj

csvfiles = [f for f in oslist(Folder) if f.endswith(".csv")

datefile = [f[:8] for f in csvfiles]

return datefiles

",

attr([Project]))

 

#Code to read a specific file based on csvfiles filter

#The reason to return a value list, because I don't know how to return the whole dataset

#If we can return a dataframe directly, it will great. Otherwise, I need to repeat this step many many time to get the value I want

script_str(

"

import pandas as pd

import os

Proj = _arg1 # Project filter

DT = _arg2 # The csv file filter

Folder = r"C:\Samples\" + Proj

csvfiles = [f for f in oslist(Folder) if f.endswith(".csv")

for item in csvfiles:

     if DT in item:

          df = pd.read_csv(Folder + "//" + item)

return df["Value"].tolist()

",

attr([Project]), attr([Date]))

0/9000

I'm not sure the best way to put this into words, so I wrote it out in what I hope is an English legible pseudo code. # denotes a comment for explanation purposes. I've been trying to do this in tableau with LOD descriptions, for example {FIXED [Subscriber ID]:COUNT([Subscriber ID])} counts the number of instances of the same ID but it doesn't exclude those not made within 24 hours of one another. Any help would be greatly appreciated

 

for each entry:

     get list of all other entries with same UserID

          for each entry in list:

               if thisEntry.date-entryWithSameUserID.date < 24 hours:

                    add to resultsList

                    break

 

⌗now I have a results list with a bunch of entries that were logged

⌗within 24 hours of one another from the same user ID

⌗note that if a user made 2 entries in our data base on 1/1/2019

⌗and then the same user made 2 entries in our data base on 2/2/2019

⌗the same user would be in our results list multiple times for the

⌗two seperate occasions that s/he made multiple purchases within 24 hours

 

for each entry in resultsList

     ⌗get how many entries were made within a 24 hour period per ID

     Count instances of each ID

 

     ⌗get which purchases led to more purchases within 24 hours

     ⌗ex. if someone buys a puppy, are they likely to also buy a bed within 24 hours?

     ⌗ex. if someone buys a puppy, are they likely to also buy a bed AND food within 24 hours?

     for each set of purchases made within 24 hours

          count which purchases were made with the earliest date

3 réponses
  1. 1 mai 2019, 19:52

    The relative date will consider the computer date (unless you specify at the bottom that the date is relative to a specific date).

     

    But this can cause problems if your data is not updated. If someday you don't have your data refresh done the dashboard will appear empty (which is never good).

     

    To address that I had to apply something like this LOD on a dashboard I built:

     

    {FIXED [Dimension] :

        SUM(IIF(DATETRUNC('day', [Date]) = [MAX Date],[Measure],NULL))

    }

     

    And the MAX Date field is just a check on your MAX(Date) (which you can define as anything you want). For me it looks like this:

     

    DATE({MAX([Date])})

     

    I hope these helps.

    Rodrigo

0/9000