title: How to split CSV content by punctuation marks
body: <p>I have a csv file with two columns, one with the name of a person and the other with words defined by the person, the problem is that in this column there are many words that are separated by punctuation marks. I need to separate these words so that each person only has one word per column, that is:</p>
  <pre><code>name,word
  Oliver,&quot;water,surf,windsurf&quot;
  Tom,&quot;football, striker, ball&quot;
  Anna,&quot;mountain;wind;sun&quot;
  Sara,&quot;basketball; nba; ball&quot;
  Mark,&quot;informatic/web3.0/e-learning&quot;
  Christian,&quot;doctor - medicine&quot;
  Sergi,&quot;runner . athletics&quot;
  </code></pre>
  <p>These are an example of the CSV data. As you can see, there are data separated by different punctuation marks (there are still some more) where they are separated by a space and others that are not. The result I would like to achieve is:</p>
  <pre><code>name,word
  Oliver,water
  Oliver,surf
  Oliver,windsurf
  Tom,football
  Tom,stricker
  Tom,ball
  Anna,mountain
  Anna,wind
  Anna,sun
  Sara,basketball
  Sara,nba
  Sara,ball
  Mark,informatic
  Mark,web3.0
  Mark,e-learning
  Christian,doctor
  Christian,medicine
  Sergi,runner
  Sergi,athletics
  </code></pre>
  <p>I have opened the file using pandas where I have created a dataframe with the data and this is where I have to separate the data. What I have tried is:</p>
  <pre><code>def splitter(df):
  
      df['word'] = df['word'].str.split(&quot;,&quot;)
      df = df.explode(&quot;word&quot;)
  
      df['word'] = df['word'].str.split(&quot;, &quot;)
      df = df.explode(&quot;word&quot;)
  
      df['word'] = df['word'].str.split(&quot; , &quot;)
      df = df.explode(&quot;word&quot;)
  
      df['word'] = df['word'].str.split(&quot;- &quot;)
      df = df.explode(&quot;word&quot;)
  
      df['word'] = df['word'].str.split(&quot; -&quot;)
      df = df.explode(&quot;word&quot;)
  
      df['word'] = df['word'].str.split(&quot;\. &quot;)  
      df = df.explode(&quot;word&quot;)
  
      df['word'] = df['word'].str.split(&quot;;&quot;)
      df = df.explode(&quot;word&quot;)
  
      df['word'] = df['word'].str.split(&quot;; &quot;)
      df = df.explode(&quot;word&quot;)
  
      df['word'] = df['word'].str.split(&quot; ;&quot;)
      df = df.explode(&quot;word&quot;)
  
      df['word'] = df['word'].str.split(&quot; ; &quot;)
      df = df.explode(&quot;word&quot;)
  
      df['word'] = df['word'].str.split(&quot;/ &quot;)
      df = df.explode(&quot;word&quot;)
  
  return df
  </code></pre>
  <p>The result I get is the one I want but with some spaces and they don't have to appear:</p>
  <pre><code>name,word
  Oliver,water
  Oliver,surf
  Oliver,windsurf
  Tom,football
  Tom, stricker
  Tom, ball
  Anna,mountain
  Anna,wind
  Anna,sun
  Sara,basketball
  Sara, nba
  Sara, ball
  Mark,informatic
  Mark,web3.0
  Mark,e-learning
  Christian,doctor
  Christian, medicine
  Sergi,runner
  Sergi, athletics
  </code></pre>
  <p>How could I solve this problem and improve the code I have put in, since I do not know how to modify it so that everything works correctly?</p>