title: How do I extract specific rows from a CSV and format the data in R?
body: <p>I have a CSV file that contains thousands of lines like this:</p>
  
  <pre><code>1001;basket/files/legobrick.mp3
  4096;basket/files/sunshade.avi
  2038;data/lists/blockbuster.ogg
  2038;data/random/noidea.dat
  </code></pre>
  
  <p>I want to write this to a new CSV file but include only rows which contain '.mp3' or '.avi'.  The output file should be just one column and look like this:</p>
  
  <pre><code>"basket/files/legobrick.mp3#1001",
  "basket/files/sunshade.avi#4096",
  </code></pre>
  
  <p>So the first column should be suffixed to the second column and separated by a hash symbol and each line should be quoted and separated by a comma as shown above.</p>
  
  <p>The source CSV file does not contain a header with column names.  It's just data.</p>
  
  <p>Can someone tell me how to code this in R?</p>
  
  <p>Edit (following marked answer): This question is not a duplicate because it involves filtering rows and the output code format is completely different requiring different processing methods.  The marked answer is also completely different which really backs up my assertion that this is not a duplicate.</p>