This Python script extracts the lyrics of songs from the Genius API, given the artist and song name, and saves them to an Excel file.
- Python 3
lyricsgenius
Python library (pip install lyricsgenius
)openpyxl
Python library (pip install openpyxl
)
Before running the script, you need to obtain an API key from the Genius API. Once you have the key, replace the placeholder xxxxxxxxxxxx
in the code with your own key.
The input file song_artist.csv
should contain the artist and song name of the songs to extract lyrics for, with a header row. An example input file:
Artist | Song |
---|---|
Bob Marley | One Love |
Sean Paul | Temperature |
The script generates an Excel file lyrics.xlsx
with three columns: Artist
, Song
, and Lyrics
.
This script was used as part of a data analytics project where the extracted lyrics of famous Jamaican songs were used to support research into whether or not Jamaican Creole was converging to English. In R Studio, the lyrics were parsed and the number of English words present in songs was counted.