Publish Spotify Chart to Tableau Public via Web Browser

Krisna Renaldi
4 min readAug 31, 2021

--

Now we can use Tableau Public in a browser as a release 2021.1.

Photo by Kindel Media from Pexels

Tableau Public has added more features to browser. We can start creating visualization and use the latest features without installing or updating Tableau Desktop to connect to data. It could save us more time to switch between Tableau Desktop and web browser.

In my previous article, I have talked about Spotify data and how these data can helped me to get information about people’s mood. Now, I will not explore data, but simply upload data to Tableau Public via web browser.

I will make three charts:

  • Number of stream over time
  • Most popular song
  • Most popular artist

Data Acquisition

Spotify release latest chart daily in weekly in format Top 200 and Viral 50. It also can be chosen from regional/country and date. For this purpose, I will get chart data daily from 1st Jan to 31st Dec 2020 with regional Indonesia.

I have explained how I scraped data using Python and BeautifulSoup, and you can read it here. And here, I have collected 366 files in csv format.

CSV files

I merge these files into one csv file because I need extra column ‘date’. The process is simple enough. I scan files under folder “2020” where I kept all my csv files, and saved it into a list. Then, in a loop, I read file csv and wrote it to new file. Here is the snippet code:

There is another way, namely using pandas.concat method as explained it here. The final file was consist of 73,201 rows with five columns: position, track, artist, stream, url, date.

Upload to Tableau Public:

Go ahead Sign Up and click “Create Vis” button to create new visualization. It will show modal dialog window to connect data, either by selecting a file to upload or just dragging and dropping files onto the dialog.

After finishing upload, Tableau Public will redirect to “New Workbook” page. When you see the left bar like this image below:

Extra fields on table

You see there are F7 — F10 field whereas the columns only consist of five columns: position, track, artist, stream, url, date. What had happened? I looked into csv file, then I saw there were some song who sang by more than one artist. Example: “Cinta Luar Biasa” by “Yovie Widianto, Tulus, Glenn Fredly”. Tableau Public will separate string based on comma but it did not know which string belong to which column/feature. The solution is rather simple. Let us convert csv file to excel file (xlsx). Finally, Tableau showed five fields.

Number of Streams

In a new sheet (Sheet 1), drag field Date (in left bar) to Columns then use aggregate Month and SUM(Stream) to Rows. Format anyway you like.

Popular Track

Create new sheet like you always did in Excel, then drag SUM(Streams) to Columns and add Track to Rows. To sort descending by number of stream click sort icon in X axis.

Popular Artist

In a new sheet, drag URL to Columns and change the Measure to Count (Distinct), and then drag Artist to Rows. Format the chart as desired.

Create Dashboard

Now let us join the sheet onto dashboard. Just drag sheet and arrange the sheets as desired. You can add action filter if you want to.

And this is the final wrap. You can see the result here: https://public.tableau.com/app/profile/krisna.renaldi/viz/SpotifyChartIndonesia2020/Dashboard1#1

Thank you.

--

--

Krisna Renaldi

Web Developer, love back-end, math, physics and data scientiest