The name’s Code. Introducing code.
A basic look at using python to explore text using the lyrics from Bond Themes.

Exploring the lyrics of Bond themes as a way of exploring code with journalists
I’ve been prepping lectures, in particular, a lift-and-dust of my ‘gentle introduction to code’ lecture that I do with my MA Multimedia Journalism students. The aim is not to make them coders, but to introduce them to the concept of coding and how it can help automate the everyday. A good example of that is how code can help us work through mountains of data.
Whilst looking for some suitable data, Billy Ailish ‘dropped’ (which is how I believe we have to say ‘released’ these days) the latest Bond theme. Obviously, there’s a lot of speculation about what it reveals about the film and a lot of analysis about the song itself. This includes a delightfully detailed musical deconstruction by ClassicFM who like the way an “alternating IV and V chords sets up a chorus grounding the harmony of the verse with plenty of harmonic ambiguity.” Metro was one of a number of publications who took the release as an opportunity for a listicle, covering all the Bond film theme tunes.
So I thought having a dig through some data around Bond themes would be an interesting subject to ease students into some code. **
Getting some data
To start with I looked up a list of Bond themes on Wikipedia which is always good for a bit of contextual data. In this case — chart positions etc. Scraping that data into a spreadsheet is pretty easy to do using Google Sheets and its =importHTML()
formula.
=importHTML(“https://en.wikipedia.org/wiki/James_Bond_music#Title_themes","Table",2)
I also scraped in the chart positions for each song. The Wikipedia page has them in but there were some gaps and whilst double-checking them, I discovered a post from the Offical Chart Company with “Every James Bond theme ever and where they charted”. I thought they might be a bit more reliable, so I scrapped that into Google Sheets too.
=IMPORTHTML(“https://www.officialcharts.com/chart-news/every-james-bond-theme-ever-and-where-they-charted__10670/","table",1)
With a bit of cut-and-paste and some cleaning up with find and replace and the trim()
function to get rid of some pesky spaces and line breaks (\n) at the end of the film titles, I had the workable basic data set with a little bit of context shown below.
film | year | bond | song | artist | peak_position | weeks_in_top_100 | |
---|---|---|---|---|---|---|---|
Dr. No | 1962 | Connery | 20 | 13 | |||
From Russia with Love | 1963 | Connery | From Russia with Love | Matt Monro | 13 | 11 | |
Goldfinger | 1964 | Connery | Goldfinger | Shirley Bassey | 21 | 9 | |
Thunderball | 1965 | Connery | Thunderball | Tom Jones | 35 | 4 | |
You Only Live Twice | 1967 | Connery | You Only Live Twice | Nancy Sinatra | 11 | 19 | |
On Her Majesty's Secret Service | 1969 | Lazenby | We Have All the Time in the World | Louis Armstrong | 3 | 19 | |
Diamonds Are Forever | 1971 | Connery | Diamonds Are Forever | Shirley Bassey | 38 | 6 | |
Live and Let Die | 1973 | Moore | Live and Let Die | Paul McCartney & Wings | 9 | 14 | |
The Man with the Golden Gun | 1974 | Moore | The Man with the Golden Gun | Lulu | |||
The Spy Who Loved Me | 1977 | Moore | Nobody Does It Better | Carly Simon | 7 | 12 | |
Moonraker | 1979 | Moore | Moonraker | Shirley Bassey | |||
For Your Eyes Only | 1981 | Moore | For Your Eyes Only | Sheena Easton | 8 | 13 | |
Octopussy | 1983 | Moore | All Time High | Rita Coolidge | 75 | 4 | |
A View to a Kill | 1985 | Dalton | A View to a Kill | Duran Duran | 2 | 16 | |
The Living Daylights | 1987 | Dalton | The Living Daylights | A-ha | 5 | 9 | |
Licence to Kill | 1989 | Dalton | Licence to Kill | Gladys Knight | 6 | 11 | |
GoldenEye | 1995 | Brosnan | GoldenEye | Tina Turner | 10 | 9 | |
Tomorrow Never Dies | 1997 | Brosnan | Tomorrow Never Dies | Sheryl Crow | 12 | 9 | |
The World Is Not Enough | 1999 | Brosnan | The World Is Not Enough | Garbage | 11 | 10 | |
Die Another Day | 2002 | Brosnan | Die Another Day | Madonna | 3 | 17 | |
Casino Royale | 2006 | Craig | You Know My Name | Chris Cornell | 7 | 19 | |
Quantum of Solace | 2008 | Craig | Another Way to Die | Jack White | 9 | 14 | |
Skyfall | 2012 | Craig | Skyfall | Adele | 2 | 32 | |
Spectre | 2015 | Craig | Writing's on the Wall | Sam Smith | 1 | 17 | |
No Time to Die | 2020 | Craig | No Time to Die | Billie Eilish |
Getting Lyrics
The next thing I wanted to do was get the lyrics for each of the songs. There’s plenty of places online to get lyrics for songs and, we’re only talking 24 songs, so some searching and cut-and-paste wouldn’t be too onerous. But I ended up using Genius.com, partly because I knew it had an API (application program interface) and I could experiment with a bit of code to download lyrics programmatically.
To get access to the API you need to sign up at https://genius.com/api-clients. Then it’s pretty straightforward. You need to define an API client (a defined use of the API). If you want to try the code yourself, you’ll also need to generate an ‘access token’ to use later in the code (if you want to try it yourself that is)

Python and Genius.com
I’ve decided to use Python for this exercise because, well, reasons (see below***). I’ll run through the code here, but there’s also a Google Collabatory version of this post that lets you interact with the code. You’ll get a more detailed idea of what’s going on when the code runs there.
I started with a Python library called lyricsgenius made by John W. Miller. It boils down the Genius.com API into a few easy to use functions. For example, I can search for a song using something like:
song = genius.search_song(songname, artistname)
I’m also using a library called Pandas. It’s designed to work with structured data like CSV files. Using Pandas means I can search, edit, add and delete data like I would in a spreadsheet.
So, a little bit of GiantCap coding and I had a basic Python script that would take my spreadsheet, pull in the song name and artist and then drag in the lyrics. Again, you can see the code run in a more step-by-step way in the Google Collabatory Notebook which I’ll also update through the series.
#Import all the libraries that will help us do the task
import pandas as pd
import re
import os
import lyricsgenius
#The lyricgenius lib needs an access token to work
genius = lyricsgenius.Genius("<this is where you'd put your access token>")
#Load in the spreashsheet with the basic data
bond_df = pd.read_csv('basic_bond.csv')
#create a temprary store for the lyrics
lyrics =[]
#Work through each row of the spreadsheet and get the artist and the song title and then search Genius with that information and get the lyrics.
for song in bond_df.itertuples():
print(song[4],song[5])
song = genius.search_song(song[4], song[5])
x = song.lyrics
words = re.sub("[\(\[].*?[\)\]]", "", x)
words = words.strip()
words = os.linesep.join([s for s in words.splitlines() if s])
lyrics.append(words)
#create a new column called 'lyrics' and save all our search results in to that
bond_df['lyrics'] = lyrics
#Save the output to a new CSV file called bondwithlyrics.csv
bond_df.to_csv('bondwithlyrics.csv')
It’s worth noting that this isn’t the only way to grab lyrics from Genius. Scraping lyrics for analysis is a popular thing to do and there are loads of interesting variations on the theme that you can find searching ‘Scraping lyrics from genius.com python’.
The code above gave me the following csv file. You can see a new column called lyrics has been added at the end with all of our words.
film | year | bond | song | artist | peak_position | weeks_in_top_100 | lyrics | ||
---|---|---|---|---|---|---|---|---|---|
0 | Octopussy | 1983 | Moore | All Time High | Rita Coolidge | 75.0 | 4.0 | All I wanted was a sweet distraction for an hour or two Had no intention to do the things we've done Funny how it always goes with love When you don't look, you find But then we're two of a kind, we move as one We're an all time high We'll change all that's gone before Doing so much more than falling in love On an all time high We'll take on the world and wait So hold on tight, let the flight begin I don't want to waste a waking moment I don't want to sleep I'm in so strong and so deep, and so are you In my time I've said these words before But now I realize My heart was telling me lies For you they're true We're an all time high We'll change all that's gone before Doing so much more than falling in love On an all time high We'll take on the world and wait So hold on tight Let the flight begin So hold on tight Let the flight begin We're an all time high | |
1 | Diamonds Are Forever | 1971 | Connery | Diamonds Are Forever | Shirley Bassey | 38.0 | 6.0 | Diamonds are forever They are all I need to please me They can stimulate and tease me They won't leave in the night I've no fear that they might desert me Diamonds are forever Hold one up and then caress it Touch it, stroke it and undress it I can see every part Nothing hides in the heart to hurt me I don't need love For what good will love do me? Diamonds never lie to me For when love's gone They'll luster on Diamonds are forever Sparkling round my little finger Unlike men, the diamonds linger; Men are mere mortals who Are not worth going to your grave for I don't need love For what good will love do me? Diamonds never lie to me For when love's gone They'll luster on Diamonds are forever, forever, forever Diamonds are forever, forever, forever Forever and ever | |
2 | Thunderball | 1965 | Connery | Thunderball | Tom Jones | 35.0 | 4.0 | He always runs while others walk He acts while other men just talk He looks at this world, and wants it all So he strikes, like Thunderball He knows the meaning of success His needs are more, so he gives less They call him the winner who takes all And he strikes, like Thunderball Any woman he wants, he'll get He will break any heart without regret His days of asking are all gone His fight goes on and on and on But he thinks that the fight is worth it all So he strikes, like Thunderball | |
3 | Goldfinger | 1964 | Connery | Goldfinger | Shirley Bassey | 21.0 | 9.0 | Goldfinger He's the man The man with the Midas touch A spider's touch Such a cold finger Beckons you to enter his web of sin But don't go in Golden words he will pour in your ear But his lies can't disguise what you fear For a golden girl knows when he's kissed her It's the kiss of death from Mr. Goldfinger Pretty girl, beware of his heart of gold This heart is cold Golden words he will pour in your ear But his lies can't disguise what you fear For a golden girl knows when he's kissed her It's the kiss of death from Mr. Goldfinger Pretty girl, beware of his heart of gold This heart is cold He loves only gold Only gold He loves gold He loves only gold Only gold He loves gold | |
4 | Dr. No | 1962 | Connery | 20.0 | 13.0 | Adriane: A la nanita nana Nanita ella nanita ella Mi niña tiene sueño Bendito sea Bendito sea Belinda: A la nanita nana Nanita ella nanita ella Mi niña tiene sueño Bendito sea Bendito sea Together: Fuentecita que corre Clara y sonora Ruiseñor que a la selva Cantando llora Calla mientras la cuna se balancea A la nanita nana nanita ella A la nanita nana Nanita ella nanita ella Mi niña tiene sueño Bendito sea Bendito sea Fuentecita que corre Clara y sonora Ruiseñor que a la selva Cantando llora Calla mientras la cuna se balancea A la nanita nana nanita ella | |||
5 | From Russia with Love | 1963 | Connery | From Russia with Love | Matt Monro | 13.0 | 11.0 | From Russia with love I fly to you Much wiser since my good-bye to you I've traveled the world to learn I must return from Russia with love I've seen places, faces and smiled for a moment But oh, you haunted me so Still my tongue tied young pride Ld not let my love for you show in case you'd say no To Russia I flew but there and then I suddenly knew you'd care again My running around is through I fly to you from Russia with love | |
6 | Tomorrow Never Dies | 1997 | Brosnan | Tomorrow Never Dies | Sheryl Crow | 12.0 | 9.0 | Darling, I'm killed I'm in a puddle on the floor Waiting for you to return Oh, what a thrill Fascinations galore How you tease How you leave me to burn It's so deadly, my dear The power of having you near Until that day Until the world falls away Until you say there'll be no more goodbyes I see it in your eyes Tomorrow never dies Darling, you've won It's no fun Martinis, girls and guns It's murder on our love affair But you bet your life, every night While you're chasing the morning light You're not the only spy out there It's so deadly, my dear The power of wanting you near But until that day Until the world falls away Until you say there'll be no more goodbyes I see it in your eyes Tomorrow never dies Until that day Until the world falls away Until you say there'll be no more goodbyes I see it in your eyes Until that day Until that day Until that day... | |
7 | You Only Live Twice | 1967 | Connery | You Only Live Twice | Nancy Sinatra | 11.0 | 19.0 | You only live twice Or so it seems One life for yourself And one for your dreams You drift through the years And life seems tame 'Til one dream appears And Love is its name And love is a stranger Who'll beckon you on Don't think of the danger Or the stranger is gone This dream is for you So pay the price Make one dream come true You only live twice And love is a stranger Who'll beckon you on Don't think of the danger Or the stranger is gone This dream is for you So pay the price Make one dream come true You only live twice | |
8 | The World Is Not Enough | 1999 | Brosnan | The World Is Not Enough | Garbage | 11.0 | 10.0 | I know how to hurt, I know how to heal I know what to show and what to conceal I know when to talk and I know when to touch No one ever died from wanting too much The world is not enough But it is such a perfect place to start, my love And if you're strong enough Together we can take the world apart, my love People like us know how to survive There's no point in living if you can't feel alive We know when to kiss and we know when to kill If we can't have it all, then nobody will The world is not enough But it is such a perfect place to start, my love And if you're strong enough Together we can take the world apart, my love I feel safe I feel scared I feel ready And yet unprepared The world is not enough But it is such a perfect place to start, my love And if you're strong enough Together we can take the world apart, my love The world is not enough The world is not enough No, nowhere near enough The world is not enough | |
9 | GoldenEye | 1995 | Brosnan | GoldenEye | Tina Turner | 10.0 | 9.0 | See reflections on the water More than darkness in the depths See him surface in every shadow On the wind I feel his breath Golden eye I found his weakness Golden eye he'll do what I please Golden eye no time for sweetness But a bitter kiss will bring him to his knees You'll never know how I watched you From the shadows as a child You'll never know how it feels to be the one Who's left behind You'll never know the days, the nights The tears, the tears I've cried But now my time has come And time, time is not on your side See him move through smoke and mirrors Feel his presence in the crowd Other girls they gather around him If I had him I wouldn't let him out Golden eye not lace or leather Golden chains take him to the spot Golden eye I'll show him forever It'll take forever to see What I've got You'll never know how I watched you From the shadows as a child You'll never know how it feels to get so close And be denied It's a gold and honey trap I've got for you tonight Revenge it's a kiss, this time I won't miss Now I've got you in my sight With a Golden eye Golden, golden eye With a golden eye Golden eye | |
10 | Live and Let Die | 1973 | Moore | Live and Let Die | Paul McCartney & Wings | 9.0 | 14.0 | When you were young and your heart was an open book You used to say live and let live But if this ever changing world in which we're living Makes you give in and cry Say live and let die Live and let die What does it matter to you? When you got a job to do You got to do it well You got to give the other fellow hell You used to say live and let live But if this ever changing world in which we're living Makes you give in and cry Say live and let die Live and let die You used to say "Live and let live" yeah | |
11 | Quantum of Solace | 2008 | Craig | Another Way to Die | Jack White | 9.0 | 14.0 | Another ringer with the slick trigger finger for Her Majesty Another one with the golden tongue poisoning your fantasy Another bill from a killer, turned a thriller to a tragedy Yeah, a door left open, a woman walking by A drop in the water, a look in your eye A phone on the table, a man on your side Or someone that you think that you can trust It's just another way to die Another tricky little gun giving solace to the one That'll never see the sun shine Another inch of your life sacrificed for your brother, in the nick of time Another dirty money, heaven sent honey, turning on a dime Well, a door left open, a woman walking by A drop in the water, a look in your eye A phone on the table, a man on your side Or someone that you think that you can trust It's just another way to die It's just another Hey! It's just another You're nothing to me, die It's just another Shoot 'em, bang bang! Another girl with her finger on the world Singing to you what you wanna hear Another gun thrown down in surrender took away your fear, hey Another man there, he stands right behind you looking in the mirror A door left open, a woman walking by A drop in the water, a look in the eye A phone on the table, a man on your side Or someone that you think that you can trust It's just another way to die It's just another It's just another It's just another way! Shoot 'em up, bang bang Hey! Hey! It's just another Yeah! Yeah! It's just another It's just another It's just another It's just another day! Bang bang bang bang | |
12 | For Your Eyes Only | 1981 | Moore | For Your Eyes Only | Sheena Easton | 8.0 | 13.0 | For your eyes only, can see me through the night For your eyes only, I never need to hide You can see so much in me So much in me that's new I never felt, until I looked at you For your eyes only, only for you You see what no one else can see Now I'm breaking free For your eyes only, only for you The love I know you need in me The fantasy you freed in me Only for you, only for you For your eyes only, the nights are never cold You really know me, that's all I need to know Maybe I'm an open book Because I know you're mine But you won't need to read between the lines For your eyes only, only for you You see what no one else can see Now I'm breaking free For your eyes only, only for you The passions that collide in me The wild abandoned side of me Only for you, for your eyes only | |
13 | The Spy Who Loved Me | 1977 | Moore | Nobody Does It Better | Carly Simon | 7.0 | 12.0 | Nobody does it better Makes me feel sad for the rest Nobody does it half as good as you Baby, you’re the best I wasn’t looking But somehow you found me I tried to hide from your love light But like heaven above me The spy who loved me Is keeping all my secrets safe tonight And nobody does it better Though sometimes I wish someone could Nobody does it quite the way you do Why d’you have to be so good? The way that you hold me Whenever you hold me There’s some kind of magic inside you That keeps me from running But just keep it comin’ How’d you learn to do the things you do? Oh, and nobody does it better Makes me feel sad for the rest Nobody does it half as good as you Baby, baby, darlin’ you’re the best Baby you're the best Darlin', you're the best Baby you're the best | |
14 | Casino Royale | 2006 | Craig | You Know My Name | Chris Cornell | 7.0 | 19.0 | If you take a life do you know what you'll give? Odds are, you won't like what it is When the storm arrives, would you be seen with me? By the merciless eyes I've deceived? I've seen angels fall from blinding heights But you yourself are nothing so divine Just next in line Arm yourself because no one else here will save you The odds will betray you And I will replace you You can't deny the prize, it may never fulfill you It longs to kill you Are you willing to die? The coldest blood runs through my veins You know my name If you come inside things will not be the same When you return to the night And if you think you've won You never saw me change The game that we have been playing I've seen this diamond cut through harder men Than you yourself, but if you must pretend You may meet your end Arm yourself because no one else here will save you The odds will betray you And I will replace you You can't deny the prize, it may never fulfill you It longs to kill you Are you willing to die? The coldest blood runs through my veins Try to hide your hand Forget how to feel Life is gone with just a spin of the wheel Arm yourself because no one else here will save you The odds will betray you And I will replace you You can't deny the prize, it may never fulfill you It longs to kill you Are you willing to die? The coldest blood runs through my veins You know my name You know my name You know my name You know my name You know my name You know my name You know my name | |
15 | Licence to Kill | 1989 | Dalton | Licence to Kill | Gladys Knight | 6.0 | 11.0 | Ooooh Ah-aaah I feel, I need, I've got to hold on to your love Ooooh Hey baby, thought you were the one who tried to run away Ohh, baby, wasn't I the one who made you want to stay? Please don't bet that you'll ever escape me Once I get my sights on you I got a licence to kill And you know I'm going straight for your heart Got a licence to kill Anyone who tries to tear us apart License to kill Hey baby, think you need a friend to stand here by your side? Yes you do Ohh, baby, now you can depend on me to make things right Please don't bet that you'll ever escape me Once I get my sights on you I got a licence to kill And you know I'm going straight for your heart Got a licence to kill Anyone who tries to tear us apart Got a licence to kill And you know I'm going straight for your heart Got a licence to kill Anyone who tries to tear us apart Say that somebody tries to make a move on you In the blink of an eye, I will be there too And they better know why I'm gonna make them 'em pay 'Til their dying day 'Til their dying day 'Til their dying day Got a licence to kill And you know I'm going straight for your heart, baby Got a licence to kill Anyone who tries to tear us apart I got a licence to kill And you know I'm heading straight for your heart Got a licence to kill Anyone who tries to tear us apart Licence to kill Gotta hold onto your loving Licence to kill Ooh, kill | |
16 | The Living Daylights | 1987 | Dalton | The Living Daylights | A-ha | 5.0 | 9.0 | Hey driver, where we going? I swear my nerves are showing Set your hopes up way too high The living's in the way we die Comes the morning and the headlights fade away Hundred thousand people, I'm the one they frame I've been waiting long for one of us to say "Save the darkness, let it never fade away" Oh, the living daylights Oh, the living daylights All right, hold on tight now It's down, down to the wire Set your hopes up way too high The living's in the way we die Comes the morning and the headlights fade away Hundred thousand changes, everything's the same I've been waiting long for one of us to say "Save the darkness, let it never fade away" Oh, the living daylights Oh, the living daylights Oh, the living daylights Comes the morning and the headlights fade away Hundred thousand people, I'm the one they frame Oh, the living daylights Oh, the living daylights Oh, the living daylights Set your hopes up way too high The living's in the way we die Set your hopes up way too high The living's in the way we die Set your hopes up way too high The living's in the way we die Set your hopes up way too high The living's in the way we die Set your hopes up way too high The living's in the way we die | |
17 | On Her Majesty's Secret Service | 1969 | Lazenby | We Have All the Time in the World | Louis Armstrong | 3.0 | 19.0 | We have all the time in the world Time enough for life To unfold all the precious things Love has in store We have all the love in the world If that's all we have you will find We need nothing more Every step of the way Will find us With the cares of the world Far behind us We have all the time in the world Just for love Nothing more, nothing less Only love Every step of the way Will find us With the cares of the world Far behind us, yes We have all the time in the world Just for love Nothing more, nothing less Only love Only love | |
18 | Die Another Day | 2002 | Brosnan | Die Another Day | Madonna | 3.0 | 17.0 | I'm gonna wake up, yes and no I'm gonna kiss some part of I'm gonna keep this secret I'm gonna close my body now I guess, die another day I guess, die another day I guess, die another day I guess, die another day I guess I'll die another day I guess I'll die another day I guess I'll die another day I guess I'll die another day Sigmund Freud Analyze this Analyze this Analyze this, this, this, this, this I'm gonna break the cycle I'm gonna shake up the system I'm gonna destroy my ego I'm gonna close my body now I think I'll find another way There's so much more to know I guess I'll die another day It's not my time to go For every sin, I'll have to pay A time to work, a time to play I think I'll find another way It's not my time to go I'm gonna avoid the cliché I'm gonna suspend my senses I'm gonna delay my pleasure I'm gonna close my body now I guess, die another day I guess I'll die another day I guess, die another day I guess I'll die another day I think I'll find another way There's so much more to know I guess I'll die another day It's not my time to go Uh! Uh! I need to lay down I guess, die another day I guess I'll die another day I guess, die another day I guess I'll die another day Another day Another day Another day Another day Another day Another day Another day | |
19 | A View to a Kill | 1985 | Dalton | A View to a Kill | Duran Duran | 2.0 | 16.0 | Meeting you with a view to a kill Face to face in secret places, feel the chill Nightfall covers me, but you know the plans I'm making Still overseas, could it be the whole Earth opening wide A sacred why, a mystery gaping inside A week is why, until we... Dance into the fire That fatal kiss is all we need Dance into the fire To fatal sounds of broken dreams Dance into the fire That fatal kiss is all we need Dance into the fire The choice for you is the view to a kill Between the shades assassination standing still Earth's crystal tears, the fall of snowflakes on your body First time in years to drench your skin in lover's rosy stain A chance to find the phoenix for the flame A chance to die, but can we... Dance into the fire That fatal kiss is all we need Dance into the fire To fatal sounds of broken dreams Dance into the fire That fatal kiss is all we need Dance into the fire When all we see is the view to a kill | |
20 | Skyfall | 2012 | Craig | Skyfall | Adele | 2.0 | 32.0 | This is the end Hold your breath and count to ten Feel the Earth move, and then Hear my heart burst again For this is the end I've drowned and dreamt this moment So overdue, I owe them Swept away, I'm stolen Let the sky fall When it crumbles We will stand tall Face it all together Let the sky fall When it crumbles We will stand tall Face it all together At Skyfall At Skyfall Skyfall is where we start A thousand miles and poles apart Where worlds collide and days are dark You may have my number You can take my name But you'll never have my heart Let the sky fall When it crumbles We will stand tall Face it all together Let the sky fall When it crumbles We will stand tall Face it all together At Skyfall Let the sky fall When it crumbles We will stand tall Let the sky fall When it crumbles We will stand tall Where you go I go What you see I see I know I'd never be me Without the security Of your loving arms Keeping me from harm Put your hand in my hand And we'll stand Let the sky fall When it crumbles We will stand tall Face it all together Let the sky fall When it crumbles We will stand tall Face it all together At Skyfall Let the sky fall We will stand tall At Skyfall | |
21 | Spectre | 2015 | Craig | Writing's on the Wall | Sam Smith | 1.0 | 17.0 | I've been here before But always hit the floor I've spent a lifetime runnin' And I always get away But with you I'm feeling something That makes me want to stay I'm prepared for this I never shoot to miss But I feel like a storm is coming If I'm gonna make it through the day Then there's no more use in runnin' This is something I gotta face If I risk it all Could you break my fall? How do I live? How do I breathe? When you're not here I'm suffocating I wanna feel love run through my blood Tell me is this where I give it all up? For you I have to risk it all Cause the writing's on the wall A million shards of glass That haunt me from my past As the stars begin to gather And the light begins to fade When all hope begins to shatter Know that I won't be afraid If I risk it all Could you break my fall? How do I live? How do I breathe? When you're not here I'm suffocating I wanna feel love, run through my blood Tell me is this where I give it all up? For you I have to risk it all Cause the writing's on the wall The writing's on the wall How do I live? How do I breathe? When you're not here I'm suffocating I wanna feel love, run through my blood Tell me is this where I give it all up? How do I live? How do I breathe? When you're not here I'm suffocating I wanna feel love run through my blood Tell me is this where I give it all up? For you I have to risk it all Cause the writing's on the wall | |
22 | The Man with the Golden Gun | 1974 | Moore | The Man with the Golden Gun | Lulu | 0.0 | 0.0 | He has a powerful weapon He charges a million a shot An assassin that's second to none The man with the golden gun Lurking in some darkened doorway Or crouched on a roof top somewhere In the next room, or this very one The man with the golden gun Love is required whenever he's hired It comes just before the kill No-one can catch him, no hit man can match him For his million dollar skill One golden shot means another poor victim Has come to a glittering end For a price, he'll erase anyone The man with the golden gun His eye may be on you or me Who will he bang? We shall see Oh yeah! Love is required whenever he's hired It comes just before the kill No-one can catch him, no hit man can match him For his million dollar skill One golden shot means another poor victim Has come to a glittering end If you want to get rid of someone The man with the golden gun Will get it done He'll shoot anyone With his golden gun | |
23 | Moonraker | 1979 | Moore | Moonraker | Shirley Bassey | 0.0 | 0.0 | Where are you Why do you hide Where is that moonlight trail that leads to your side Just like the moonraker goes In search of his dream of gold I search for love For someone to have and hold I've seen your smile In a thousand dreams Felt your touch And it always seems You love me You love me Where are you When will we meet Take my unfinished life and make it complete Just like the moonraker knows His dream will come true someday I know that you Are only a kiss away I've seen your smile In a thousand dreams Felt your touch And it always seems You love me You love me | |
24 | No Time to Die | 2020 | Craig | No Time to Die | Billie Eilish | I should have known I'd leave alone Just goes to show That the blood you bleed is just the blood you owe We were a pair But I saw you there Too much to bear You were my life, but life is far away from fair Was I stupid to love you? Was I reckless to help? Was it obvious to everybody else? That I'd fallen for a lie You were never on my side Fool me once, fool me twice Are you death or paradise? Now you'll never see me cry There's just no time to die I let it burn You're no longer my concern, mmm Faces from my past return Another lesson yet to learn That I'd fallen for a lie You were never on my side Fool me once, fool me twice Are you death or paradise? Now you'll never see me cry There's just no time to die No time to die, mmm No time to die, ooh Fool me once, fool me twice Are you death or paradise? Now you'll never see me cry There's just no time to die |
If you have a quick look through the file you’ll see that Dr No is still causing us problems (the metal hands I guess). We’ve got the lyrics to “A La Nanita Nana” - A Spanish lullaby. The reason for this is that Pandas replaces empty cells with the value Nan or ‘not a number’. When the script searched genius.com it used nan as the search term! We’ll need to remember that the lyrics for Dr No are ‘wrong’ for later.
How ‘long’ is a Bond song?
Looking at the lyrics that I scraped from Genius, I noticed that some songs had more words than others. So I thought it would be fun to compare them. To do that, I needed a quick way to count all the words and then compare them.
The following code does that. It uses pandas again to store the content of the csv file in a temporary object called bond_df
We can then tweak and play with the data. In this case, we can count the number of words in each song and save that as a number.
# Load the csv with lyrics into a dataframe
bond_df = pd.read_csv('bondwithlyrics.csv')
# Take the lyrics from each song and split them up when you find a space.
# Count up the number of words and put that into a new column called 'wordcount'.
bond_df['wordcount'] = bond_df.lyrics.apply(lambda x: len(str(x).split(' ')))
It’s a rough and ready approach, but it does mean I can ask some quick questions. For example, which one had the most words…
#Show me the row in my data that equals the highest valuebond_df.nlargest(1,'wordcount')
The result is Sam Smith’s 2015 ‘Writing’s on the wall’ with 255 words. The shortest…
#Show me the row in my data that equals the highest valuebond_df.nsmallest(1,'wordcount')

We get a weird one here. The shortest in my data is actually Dr No, which, as we know is actually the Spanish lullaby. So I need to expand my search a bit…
#Show me the 5 lowest wordcounts
bond_df.nsmallest(5,'wordcount')

That list shows Matt Munro’s ‘From Russia with love’ has the least lyrics at 78. I also noticed that all of the lowest wordcounts came from early Bond films. It made me wonder if the songs got longer over time — from the 78 of From Russia with love to the 255 of Writing’s on the wall. A quick chart should tell us that…
# Import a library for making charts.
import matplotlib.pyplot as plt
#Plot a scatter chart to show wordcount against year
bond_df.plot(kind='scatter',x='year',y='wordcount')
The resulting chart, suggests a trend towards longer songs — in wordcount at least.

Here’s the same plot with a trend line added to show that trend. I’ve pulled in another library here called Seaborn, which adds some extra visualisation functionality including showing the relationship between the wordcount and year.
import seaborn as sns
#Plot the wordcount against year and show the relationship between the two
sns.regplot(y="year", x="wordcount", data=bond_df);

As I thought, a trend towards more lyrics. But does that mean that the songs are getting more complex? Longer? Maybe all pop songs are. Maybe there are more words but they are the same ones. How many times does Shirley Bassey belt out ‘Goldfinger’?
Conclusions
It was surprisingly easy to get a long way down the line with this, just with Google Sheets. What Python did best was to take over on the repetitive stuff — scraping lyrics, counting words etc. And that’s the point. It could be text Bond lyrics to political speeches. Once we have the words in a structured format, coding can help us quickly get to the point where we can start asking questions. I’ve been pretty free with pulling in Libraries to do some of the work for me. That’s, in part down to my magpie-like coding practice. I cut and paste stuff to make it work. In that sense it’s not ‘good code’ but it works.
In the next in this series, I’ll dig a little deeper into lyrics and see what else we can dig up. In the meantime. I hope its whetted your appetite for a bit of code (or a bit of bond)
** In terms of method, this exercise has loads of problems. The choice of Bond themes for example. I’m counting From Russia with Love as the theme to the film of the same name. It wasn’t. The music was, but you only get a hint of Matt crooning over a radio in the early part of the film. So, yes you can drive a bus through the data, but it’s a means to an end.
*** Why Python? I’m a big fan of the Python programming language. It’s one of two that dominate the “journalists that code” and data journalism fields. The other is R. Both are great. You’d benefit from being familiar with both. But I went with Python for this example because a)it’s good for text analysis (yes I know R is too) and I know it well. That’s it really.