In this blog, we'll dive 🌊🤿 into building a Streamlit-based dashboard for analyzing Spotify User Sentiment using Airbyte for data extraction, Motherduck (DuckDB) for storage and querying, and Daytona for streamlined development environments. This project explores how these technologies integrate with Streamlit to create an interactive and insightful data analysis application.
📁 Folder Structure Overview
SPOTIFY-REVIEWS-ANALYSIS
├── .devcontainer
│ ├── devcontainer.json
├── .streamlit
│ ├── config.toml
├── assets
│ ├── main.png
├── src
│ ├── config
│ │ ├── __init__.py
│ │ ├── config.py
│ ├── utils
│ │ ├── __init__.py
│ │ ├── database.py
│ ├── app.py
├── .env
├── venv
├── .gitignore
├── LICENSE.md
├── README.md
├── requirements.txt
.devcontainer/devcontainer.json: Configures development environment.
.streamlit/config.toml: Streamlit's UI style and configuration.
assets: Stores static assets like images.
src/config/config.py: Handles environment variables.
src/utils/database.py: Queries data from Motherduck.
src/app.py: Streamlit dashboard and logic.
.env: Stores environment variables securely.
👉 Tips On Folder Structure
SPOTIFY-REVIEWS-ANALYSIS: This is the outer folder of the repository.
src: This folder contains config and utils for project logic.
☀️ Daytona Integration
Daytona is an open-source Development Environment Manager (DEM) designed to simplify and streamline the process of setting up development environments.
🛠️ Why Daytona?
Consistency: Ensures uniform development environments across all team members.
Scalability: Manages multiple environments seamlessly.
Security: Isolates and secures environments.
Efficiency: Reduces overhead during setup and switching between environments.
📚 Daytona Setup
Installation: Follow the .
📊 Core Logic of Sentiment Analysis
Sentiment analysis is powered by TextBlob to determine the polarity (positive/negative sentiment) and subjectivity (factual/opinionated content) of reviews.
🧠 Sentiment Analysis Function
CODEfrom textblob import TextBlob
def get_sentiment(text):
blob = TextBlob(str(text))
return blob.sentiment.polarity if sentiment_type == "Polarity" else blob.sentiment.subjectivity
📈 Visualization Example
CODEfig = px.histogram(reviews_df, x='sentiment', title='Sentiment Distribution')
st.plotly_chart(fig)
🦆 Database Integration with Motherduck
🔗 database.py
CODEimport duckdb
from config.config import MOTHERDUCK_TOKEN
def get_connection():
return duckdb.connect(f"md:?token={MOTHERDUCK_TOKEN}")
def get_reviews_for_sentiment():
conn = get_connection()
query = """
SELECT content, score FROM spotify_reviews WHERE content IS NOT NULL
"""
return conn.execute(query).fetch_df()
This code fetches Spotify review data securely using MOTHERDUCK_TOKEN stored in
.envthroughconfig.pyfile.
🗂️ config.py
CODEimport os
from dotenv import load_dotenv
load_dotenv()
MOTHERDUCK_TOKEN = os.getenv("MOTHERDUCK_TOKEN")
🔄 Connection Betweenapp.pyanddatabase.py
The
app.pyimportsget_reviews_for_sentimentfromdatabase.py, creating a seamless flow of data into the dashboard.
🎯 Conclusion
We successfully built a Spotify Reviews Sentiment Analysis Dashboard using Airbyte, Motherduck, Streamlit, and Daytona. This project demonstrates the power of consistent development environments, robust data storage, and insightful visualization.
.
📺 Live PROJECT https://spotify-sentiment-analysis.streamlit.app
Sentiment Analysis #Happy Coding! #Daytona 🚀🦆
↗ Original-Artikel auf dev.to lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
SOCIAL SHARE CARD GENERATOR