title: Defining a duplicate row by the first 20 characters of a cell
body: <p>I am running a basic de-duplication script for a Google spreadsheet and have hit  roadblock. I want to base whether or not a row is a duplicate on only the first 20 characters in the columns I have defined, not the entire contents of the column.</p>
  
  <p>I ran multiple searches and haven't found anything even close. I keep coming up with ways to remove the first X characters, but that doesn't do me any good.</p>
  
  <p>Any help is greatly appreciated. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>function removeDuplicates() {
    var sheet = SpreadsheetApp.getActiveSheet();
    var data = sheet.getDataRange().getValues();
    var newData = new Array();
    for(i in data){
      var row = data[i];
      var duplicate = false;
      for(j in newData){
        if(row[0] == newData[j][0] &amp;&amp; row[4] == newData[j][4]){
    duplicate = true;
  }
      }
      if(!duplicate){
        newData.push(row);
      }
    }
    sheet.clearContents();
    sheet.getRange(1, 1, newData.length, newData[0].length).setValues(newData);
  }</code></pre>
  </div>
  </div>
  </p>