I want to write this into the range B1..
=split(A1," ")
(the delimiter is a space)
How do I do it using code?
I tried this...
var splitCell = "=SPLIT(A1," ")";
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange("B1").setFormula(splitCell);
But the quotes are obviously ruinous. Therefore how are quotes handled in such instances?
EDIT
Sorry. Brain-fart.
var splitCell = '=SPLIT(A8," ")';
I thought that I had already tried that (about a million times) but when I just tried it (again) it worked no problem.
Thanks anyway
(I'm sure I'll be back with less smelly questions in the future)
At the time that I asked my question, I was not allowed to answer my own question (newbies here have limitations). However the answer to my question was stated in the "edited" part of my question.
I apologize for the confusion, but at the time I had no other options available to me, so therefore my question remained "Unanswered" even though I already resolved it.
Anyway, the answer is:
var splitCell = '=SPLIT(A8," ")';
Related
This question already has an answer here:
Cannot find method getRange(number,number)?
(1 answer)
Closed 5 months ago.
I am really sorry.. this is probably going to be the dumbest question you have seen in a good long time, if not ever... LOL I have been pulling my hair out on this for two hours and for the life of me I can't figure out what I am doing wrong...
This is stupid simple. It is a simple SpreadsheetApp.getRange() using the alternate parameters instead of your the usual "A1" reference. I am sure I am screwing up the syntax, but for the life of me I can't seem to figure out or find what it is that I am doing wrong...
This ties in with a larger project, of course, but for the sake of simplicity, this is what I currently have:
function test() {
var teamSheet = SpreadsheetApp.getActive();
teamSheet.getRange("25,25").activate();
teamSheet.getCurrentCell().setValue("Stuff");
};
All I want it to do there is go to Y25 and put in the word "Stuff". This is eventually going to end up in a loop where both the Row and Column values are increasing with each iteration - hence why I am using the alternate parameters instead of just entering "Y25".
I have tried in single quotes, double quotes, no quotes, square brackets, R[25]C[25], on and on... The error message I am getting is either Exception: Range not found or Exception: The parameters (String,number) don't match the method signature for SpreadsheetApp.Spreadsheet.getRange.
I appreciate this is a bit of a waste of your time and I am likely making some stupid, silly mistake - but I don't see it and I am loosing my mind on this... Please help!!
The script you provide always goes to A25 because the current cell of an active range is always the upper left corner. It's the same as this one.
function test() {
const ss = SpreadsheetApp.getActive();
ss.getRange("25:25").activate()
ss.getCurrentCell().setValue("A25");
};
I don't understand why you would want to but you could right it like this:
function test() {
const ss = SpreadsheetApp.getActive();
ss.getRange("Y25:25").activate()
ss.getCurrentCell().setValue("Y25");
};
And then it would go to Y25 and put "Y25" there or just as easily
function test() {
const ss = SpreadsheetApp.getActive();
ss.getRange("Y25").activate()
ss.getCurrentCell().setValue("Stuff");
};
If this does not answer your question let me know. Perhaps you should ask it in the context of how you wish to apply it.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I'm trying to import a list from my Gmail into a spreadsheet.
It has worked flawlessly several times, but I decided to do some cosmetic changes and now I get a baffling error:
var l = artikelen.length; //l = 40 in this case
var importSh = SpreadsheetApp.getActive().getSheetByName("import");
var range = importSh.getRange(2,1,l,1);
range.setBackground("#ab6e6e");
SpreadsheetApp.flush(); //throws error 'Input exceeds the limit of 50000 characters in a cel'
What is that? I'm not trying to put anything in a cell?? I'm just ordering to pick a range and set a colour AFAIK. Which in fact is not executed either...
What am I overlooking here?
Any suggestion will be welcome.
The culprit may be elsewhere in your code. Chances are that there is an attempt to put more than 50,000 characters in some cell.
Spreadsheet writes are lazy, and the error may only get shown when the script terminates, or at flush(), as the case seems to be here. To debug, add a flush() after every Range.setValues() and Range.setValue() call. Use console.log() to find what the values you are writing look like.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have some HTML on a page that has a bunch of tables and data (it's a report page). This is all legacy code, so no harassment necessary on the use of tables.
Given that it is legacy code, it is fragile, and we want to confirm that the table looks like we want (number of columns, rows, and the data inside of them are accurate).
My first inclination is to use selenium web driver and run through everything that way (Page Object Pattern), but a co-worker suggested that I just view source of the page, copy the table in question, and then just use this to do a string comparison in the test.
My initial thoughts on his proposal is that it is not a good test because you're starting with the answer and then writing a test to make sure you get that answer (essentially non-TDD). But I'm not sure that's a good enough answer in this case.
How should I test HTML table to make sure all columns, rows are how we like, in addition to the contents of each cell?
It depends. String matching sounds like Approval Testing, depending on just how dynamic the table is that could be fine.
If I already had Selenium tests running I'ld stick with what I have. Using findElements to count and verify the various columns, rows, and values.
Re: your comment if you cannot convince the developers to add ids, names, or something to make your job easier and you do go the Selenium route then xpath is probably what you will want to use. We've created utility methods to help in these sort of situations:
public boolean isLabeledTextPresent(String label, String text) {
WebElement element = findElement(By.xpath("//tr/th/label[contains(text(), '" +
label + "')]/ancestor::tr/td"));
String labeledText = element.getText().trim();
return labeledText.contains(text);
}
I think both methods are valid, it really depends on what you are trying to do and what advantages/disadvantages work best for you.
It would take a little work (depending on you or your teammates skill sets and experience) to write a Selenium script to scrape the table and verify certain things.
Advantages:
Once completed, it will validate very quickly and will be less fragile than method #2.
Disadvantages:
This is dependent on how quickly you can write a script and how easily you are able to validate all the things you want to validate. If all you want is # cols/rows and cell content, that should be very easy. If you want to validate things like formatting (size, color, etc.) then that starts to get a little more complicated to do through code.
It would be super easy to copy/paste HTML and validate against that. The problem is, as you pointed out, you are starting with the answer in some respects. You can get around that by validating that the HTML source for the table is correct. That will have to be done manually but once you get that, you can open the page and compare source of the table vs what you have validated.
Advantages:
You will be able to tell when anything changes... formatting, data, # cells, ... everything.
Disadvantages:
You will be able to tell when anything changes... lol. Your test will fail when anything is changed which will make the test very fragile if you expect that the table will ever get updated. If it gets updated, you will have to revalidate all the HTML for the table which could get to be a tedious process depending how often you expect this to happen. One thing that will help with this validation is to use a diffing tool... you can quickly determine what has changed and validate that instead of having to validate everything each time there is a change.
I would lean towards #1, write the script. It will be less fragile and as long as someone has the right skills shouldn't be that big of a task.
EDIT
You didn't specify what language you are working in but here's some code in Java that hopefully will point you in the right direction if you choose to write a script.
WebElement table = driver.findElement(...));
List<WebElement> rows = table.findElements(By.tagName("tr"));
Assert("Validate expected number of rows", rows.size(), expectedNoOfRows);
for (int row = 0; row < rows.size(); row++)
{
List<WebElement> cells = rows.get(row).findElements(By.tagName("td"));
Assert("Validate expected number of cells in row " + row, cells.size(), expectedNoOfCells[row]);
for (int cell = 0; cell < cells.size(); cell++)
{
Assert("Validate expected text in (" + cell + "," + row + ")", cells.get(cell).getText().trim(), expectedText[cell][row]);
}
}
You could do something like this at a basic level. If you want to get more fancy, you could add logic that looks for specific parts of the report so you can get a "landmark", e.g. Summary, Data, ... making headings up ... so you will know what to expect in the next section.
You could run a variation of this code to dump the different values, number of rows, number of cells in each row, and cell contents. Once you validate that those values are correct, you could use that as your master and do comparisons vs it. That will keep you from false fails on comparing straight HTML source. Maybe it's something in the middle between a script and text comparison based on HTML source.
I have a problem in writing in MATLAB a program that modulates data bits, adds noise then demodulates it and calculate the bit error and the symbol error rate. The modulation used first should be QPSK. I have done the following,
N=100;
databits = randi([0 3],N,1);
hModulator = comm.QPSKModulator;
hModulator.PhaseOffset = pi/4;
txsig = step(hModulator, databits);
scatterplot(txsig)
grid on
SNRdB=-10
rxsig = awgn(txsig,SNRdB);
H = comm.QPSKDemodulator
hH.PhaseOffset = pi/4;
symdecoded=step(H,rxsig)
symerr(symdecoded,databits)
biterr(symdecoded, databits)
My first question is I don't think I am doing the bit error rate and symbol error rate correctly, can someone help me spot where the problem is? Where am I missing out?
I am then asked to repeat the same problem but make the changes needed to make it work with 16-QAM and 64-QAM by changing a parameter called CONSTELLATION.
I have tried using demod and ddemodce but these two functions are removed from matlab? Does anyone know how to proceed?
I dont know why you are using SNRdB=-10 dB?
Try for example positive numbers 0 10 20 30, and you may save symerr and biterr as the function proposes [number,ratio] = symerr(x,y)
number= numb of error and ratio = bitsTx/bitsRx
For m-qam better use modem.qammod try the help in matlab
Best regards and good luck
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to elegantly ignore some return values of a MATLAB function?
I have a Matlab function with two outputs. Sometimes I use both outputs.
function [output1 output2] = myFunction(input)
[a b] = myFunction(input);
Other times I only need output1 and don't want to waste memory assigning output2
a = myFunction(input);
However, I can't figure out a simple way to give the reverse scenario (only need output2 and don't want to waste memory assigning output1). I thought it would be something like
[~ b] = myFunction(input)
but that doesn't seem to work. Anybody have suggestions for a quick solution? Thanks for your help!
It's [~, b], not [~ b]. The comma is missing.
the object will be created inside myFunction either way, unless your input has a way to prevent the creation. If you can prevent the creation internally, you can modify myFunction to return a cell array or other structure, from which you can decide which elements to keep. If your concern is that [dontwant b] is wasting matlab memory by holding dontwant, then you might want to delete dontwant from your workspace by calling
clear dontwant;