Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8882483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:35:27+00:00 2026-06-14T20:35:27+00:00

I have a google docs spreadsheet with rows like this: | | things; separated;by;semicolons;with;line;breaks

  • 0

I have a google docs spreadsheet with rows like this:

          |                | things; separated;by;semicolons;with;line;breaks |
something | something else | A;B;C;D;E;F;G                                    | one more thing
          |                | K;L;M;N;O;P;Q                                    |
-----------------------------------------------------------------------------------------------

i want to split the third column by linebreaks, putting each in one copy of the entire line, overwriting the third cell and then split that cell by the semicolons.
At the end, the previous row should be converted to something like this:

something|something else|things|separated|by|semicolons|with|line|breaks| one more thing
-----------------------------------------------------------------------------------------
something|something else|   A  |     B   | C|     D    |  E |  F |  G   | one more thing
-----------------------------------------------------------------------------------------
something|something else|   K  |     L   | M|     N    |  O |  P |  Q   | one more thing
-----------------------------------------------------------------------------------------

I tried this function, but some cells overlap and overwrite others:

function splitColumnAndRepeatRows(anArray, splitColumnIndex) {
  var output = [];
  for (i in anArray){ // for each row
    var splitArray = anArray[i][splitColumnIndex].split(/\n/g); // split values by line breaks
    for (j in splitArray){ // for each split array
      var row = anArray[i].slice(0); // copies the entire line
      row.splice(2,1,splitArray[j].split(";")); // inserts the splited values overwriting the third cell
      output.push(row);
    }
  }
  return output;
}

So the splice function doesn’t insert the split values between cells 2 and 4. The split values are placed from the third cell on, overwriting the fourth cell (“one more thing”, in the example), like this:

something|something else|things|separated|by|semicolons|with|line|breaks
------------------------------------------------------------------------

Can someone point out where is my mistake? I hope I explained it well enough.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:35:28+00:00Added an answer on June 14, 2026 at 8:35 pm

    There are two issues with your code. One is that you are replacing one cell every time you run the splice function. Since you do this many times, you overwrite that last “one more thing” cell as well. Instead, replace it once at the beginning only.

    The other issue, though I’m not sure what you intended, is I don’t think you want to supply an array to the splice function as this creates an inner array in your row array. Instead, loop over the array values and call splice with each one.

    This inner loop code should fix your issue:

    for (j in splitArray){ // for each split array
      var row = anArray[i].slice(0); // copies the entire line
      var split = splitArray[j].split(";");
      var pos = 0;
      row.splice(2,1); // deletes the third cell
      for (var k in split) {
        row.splice(2+pos,0,split[k]); // inserts the splited values starting at cell 2
        pos++;
      }
      output.push(row);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one spreadsheet of google docs with data like : 0012 0234 0065
I have three scripts that are in a google docs spreadsheet. In this spreadsheet,
I'm trying to visualize data like in this spreadsheet https://docs.google.com/spreadsheet/ccc?key=0AhtsNUEmDE6MdE0ybXppcG1jampsVnBfZWpEZm9vbmc . So I would
I have a Spreadsheet, like excel on Google Docs. I am using both Mozilla
So I have a Google Form that feeds a Google Docs Spreadsheet. This form
I have a Google Form that feeds a Google Docs Spreadsheet. I'd like to--in
I have a spreadsheet (in Google Docs, but can be any spreadsheet) with a
I have one Spreadsheet file in my Google Drive which i want to sync
Google Docs returns a long 3 line string when supplied with credentials. This is
I have an Excel Spreadsheet (technically it is a Google Docs sheet, but the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.