Home > Software design >  How to paste into google sheets with line break or newline a delimiter?
How to paste into google sheets with line break or newline a delimiter?

Time:10-11

I copy some text from Notepad and paste it into google sheets. It pastes it tab-delimited. I want it to be pasted as new-line delimited. Tabs shouldn't be taken into account for delimiting.

I tried by deleting extra columns, keeping just one. but it creates extra columns. In excel there is an option to import text with a required delimiter. In Google sheets, how to achieve this? If there is no such thing, can it be achieved via app-script?

CodePudding user response:

Just in case. Here is the little snippet that splits contents of selected cell by lines and puts these lines into bottom cells:

function split_cell() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var cell = sheet.getActiveRange();
  var value = cell.getValue();
  var cells = value.split('\n').map(x => [x]);
  sheet.getRange(cell.getRow(),cell.getColumn(),cells.length).setValues(cells)
}

CodePudding user response:

If you want to import the text from the txt file, you can simply choose the delimiter you want.

For instance, when using the Import option in Sheets:

import option

You can select a custom separator:

custom delimiter

However, if you are simply copying the text from the txt file, you may want to check the settings for the text editor you are using when it comes to the delimiter chosen.

Reference

  • Related