javascript – Google Script Retrieve URL data and randomly missing data values ​​during an iteration

I draw vehicle dimensions from a generated URL column in Google Sheets. Here's an example of a leaf I work with:

I have a function that gets all the values ​​in the "Generated URL" column. For each URL value, we retrieve the HTML code from the site and override these values:

  • Rear main room
  • Rear shoulder room
  • Loading capacity, all seats available
  • Max. Freight capacity

After running the full code, the returned vehicle dimension values ​​are never static. Sometimes the values ​​are pushed correctly to the Google Sheet, but sometimes I get my value "no data".

I used an if / else loop with isNaN to check if the value is a number before sliding it on the sheet. The else sets the value equal to "no data", which sometimes is set even if the connection contains correct data.

function getData(url, i, skip) {

  var temp = i;
  var tempurl = url;
  var options = {
    method : "GET",
    muteHttpExceptions : true

  var response = UrlFetchApp.fetch(url, options);
  var content = response.getContentText();

  var start1 = 'Rear head room';
  var end1 = 'in.';
  var start2 = 'Rear shoulder room';
  var end2 = 'in.';
  var start3 = 'Cargo capacity, all seats in place';
  var end3 = 'cu.ft.';
  var start4 = 'Maximum cargo capacity';
  var end4 = 'cu.ft.';

  //var dataa;
  var cut1 = content.indexOf(start1);
  var cut2 = content.indexOf(start2);
  var cut3 = content.indexOf(start3);
  var cut4 = content.indexOf(start4);

  var finish1 = content.indexOf(end1, cut1);
  var finish2 = content.indexOf(end2, cut2);
  var finish3 = content.indexOf(end3, cut3);
  var finish4 = content.indexOf(end4, cut4);

  var data1 = content.substring(cut1, finish1);
  var data2 = content.substring(cut2, finish2);
  var data3 = content.substring(cut3, finish3);
  var data4 = content.substring(cut4, finish4);

  var value1 = data1.substring(62, 66);
  var value2 = data2.substring(66, 70);
  var value3 = data3.substring(82, 86);
  var value4 = data4.substring(70, 75);

  var comp1 = isNaN(value1);
  var comp2 = isNaN(value2);
  var comp3 = isNaN(value3);
  var comp4 = isNaN(value4);

  var comp = new Array;

  var checktest1 = 'n" c';
  var checktest2 = 'lass';
  var checktest3 = '   2) {
    var x = 0;
    while (x <= 3) {
      if (comp(x) == true) {
        switch(x) {
          case 0:
            value1 = "No Data";
          case 1:
            value2 = "No Data";
          case 2:
            value3 = "No Data";
          case 3:
            value4 = "No Data";
      else {
    setData(value1, value2, value3, value4, temp);
  else if (value1 === checktest1 || value2 === checktest2 || value3 === checktest3 || value4 === checktest4) {
    var dataa = content;
    delete content;
    getData(tempurl, temp, skip); 

  else {
    setData(value1, value2, value3, value4, temp);


function setData(value1, value2, value3, value4, temp) {

  var index = temp - 2;
  var x = 0;
  var ss1 = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss1.getActiveSheet();
  var cell = sheet.getRange(2, 10);

  var cell1 = value1;
  var cell2 = value2;
  var cell3 = value3;
  var cell4 = value4;

  var isEmp = new Array;
  var coltest = '="">';

  while (x <= 3) {   
    if (isEmp(x) === '' || isEmp(x) === coltest) {
      switch(x) {
        case 0:
          value1 = "No Data";
        case 1:
          value2 = "No Data";
        case 2:
          value3 = "No Data";
        case 3:
          value4 = "No Data";
    else {


  cell.offset(index, 0).setValue(cell1);
  cell.offset(index, 1).setValue(cell2);
  cell.offset(index, 2).setValue(cell3);
  cell.offset(index, 3).setValue(cell4);


Of the 148 iterations, my program does not get random 20-25 lines of data. The random false lines are never the same, but contain the correct values, but were overlooked randomly.

Javascript – how do I manipulate DOM with ForEach using the iteration of HTML Collection correctly?

I'm having trouble creating elements dynamically.
I just start the code and nothing happens in the DOM. In parentObject, there is an HTML collection that is iterated eight times in forEach and creates eight simple paragraphs written as "second {iteration number)."

but I roll it and nothing happens at all.

The path of the map body is: html> body> section> div> div> # 0 div.mb-4.shadow-sm> div.card-body

const parentObject = document.getElementsByClassName("card-body");

(...parentObject).forEach((parent, i) => {
  const childElement = document.createElement("p");
  childElement.className = "card-text";
  childElement.innerText = `second ${i}`;

Efficiency – Organized data structure with efficient push, iteration, and random pop / drain

I need a data structure d with somewhat contradictory requirements. What different compromises could I make?

The same algorithm is repeated in each time step:

  • push a new element on the right (so of course all elements are sorted by the date they were added to the data structure).
  • update all elements. I mean iterate (in any order or in parallel) and mutate in place.
  • based on the result of the update, drain random elements in the order (new or old). I mean, some have to be both returned around users and away from d,
  • User should also be light iterate to talk about the remaining elements.

For example, think of a bunch of fruit whose maturation takes a random amount of time. Every day a new piece of fruit is produced. And every day we have to collect (ordered) ripe fruits and sort the remaining pieces of fruit by age.

Is there a dedicated data structure?
If not, is there a pattern for this case?
If not, what are the different compromises that I have to deal with? Is there an assumption I could make regarding the data (like the drain frequency) to help me choose?
(I suspect, for example, that many pieces of fruit are ripe on the first or the first updates and only a few hold longer)

matrix – How do I save all matrices that have been updated in each iteration?

I have a (n x m) matrix in which the elements in each iteration are recalculated and replaced with new ones. (In other words, I have a loop in which the elements of that matrix are calculated and renewed in each step.)
What is the best way to save and export all matrices?

As an example:

        ne = 4
ns = 6
avec = table[0, {ie, 1, ne}, {i, 1, ns}];
Dat = table[avec[[ie, i]]= dh + 1;
new = avec;
export[NotebookDirectory[] <> "avecexample.xls", new], {ie, 1, ne}, {i, 1, ns}]

but this only exports the last avec. My first question is how to save them all.
And in the next step, I want to know how to select certain avecs to save in the event of further iterations (for example, how to save / export only the last five avecs calculated in the loop)?

New iteration question

I have the following table

Enter image description here

And I would like to have a formula that yields the following result

Enter image description here

I want to go through the table from top to bottom from left to right. If a cell contains a value, I would like to return with the appropriate criteria for the top row. How would I do that?

python – dataframe stores only the last iteration

The last iteration of the code is stored in data frame "df1". I'm trying to create a data frame that shows the result of each iteration in a row. For example: iteration 1 in row 1, iteration 2 in row 2, and so on.

I have refrained from including the calculations for the variables because they are not relevant to the problem. Any ideas on how to do that best?

I tried to change the indent and use a for loop within the current "for path in all_possible_path" loop.

for i in range (4):
count = range (i)

Shortest_path = None
Shortest_path_length = None
for path in all_possible_path:
complete path = u + s + d
euclidean_length = total_distance (fullpath)
print ("path: {} has footage: {}". format (fullpath, euclidean_length))
df1 = [fullpath, euclidean_length]

        if the shortest_path_length is None or the shortest_path_length> Euclidean_length:
shortest_path_length = Euclidean_length
shortest_path = full path

I do not receive any error messages, but there seems to be a problem with my setup. Thanks for any help!

Iteration vs recursion question in Lisp method

I wonder if the following method is called iterative or recursive:

(define (deep-reverse article)
(define (answer things)
(cond ((null? things) answer)
((Couple? (Car stuff))
(iter (cdr things) (cons (deep-reverse (car things)) answer))
(else (iter (cdr things) (cons (auto things) answer))))
(iter items ()))

I am confused because iter calls only with the state variables things and reply as arguments and modifies them on each pass, so I think it's iterative. It is defined in a method deeply reversed that's called recursive … That's confusing to me, because this method contains both iteration and recursion elements, so I do not know how to classify them … Is deeply reversed recursively? is iter iteratively?

Many Thanks.

performance – iteration and validation of palindromes in Pari-GP

My question is, can I improve this code in terms of performance. And
maybe in other ways can you recommend? I only recently
I started trying to use pari-gp and am still getting it
familiar with it.

I want to quickly search for palindromic numbers in three consecutive number bases in pari-gp.

I iterate palindromes in base b and then check if they are also palindromes in the bases b + 1, b + 2.

I iterate palindromes by concatenating vectors:

(Where I took this specific code for base 2 and 3 and generalized it to b and b + 1, b + 2. Note that I split the forestsep loop into two parts because there are no palindromes with 0 as the middle digit repeated.)

\ Iterate 2d + 1-digit palindromes in base b and check them in bases b + 1, b + 2
check (d, b) =
my (N = b ^ d);
s = concat (vector (b-2, j, 1),[2]);
Step (i = N + 1, b + N-1, s,
my (baseb1, baseb = digits (i, b), k);
baseb = concat (Vecrev (baseb[2..d+1]), baseb);
Baseb[d+1] = baseb[d+1]-1;
k = subst (Pol (base), &x, b);
if (ispal (k, b + 1) && ispal (k, b + 2), logsolution (d, k, b););
Step (i = N + 1, b * N-1, s,
my (baseb1, baseb = digits (i, b), k);
baseb = concat (Vecrev (baseb[2..d+1]), baseb);
k = subst (Pol (base), &x, b);
if (ispal (k, b + 1) && ispal (k, b + 2), logsolution (d, k, b););

From where ispal (n, b) checks if n is a palindrome in base b:

\ true if n in base b is palindrome
ispal (n, b) =
return (digits (n, b) == Vecrev (digits (n, b)));

And logsolution (d, n, b) is just my approach to sort found examples into categories.

Graphs and networks – function iteration

In Mathematica, I have written a function that applies certain construction steps to the "incidence matrix" of a graph to get a new graph with certain properties. These construction steps can be repeated, and here is the point where I fail. When I write something like that


I get a strange error in the following form:
Error while going through the function

Now for the implementation:

Henneberg1[mats_, a_, b_] : = ...

The first parameter mats_ describes a set of (incidence) matrices in which on and b are only placeholders for variables to be added.
When I rate Henneberg1[{{{1,1,1,1}}},a,b] I will pick up

$ { begin {pmatrix}
1 & 1 & 1 & 1 & 0 & 0 \
a & 1 & 0 & 0 & -a & -1 \
0 & 0 & b & 1 & -b & -1
end {pmatrix} } $

Passing the result directly as an argument for Henneberg1 then works as intended, but I am unable to iterate in the manner described above.

The actual implementation of Henneberg1 can be found here, but it is quite a mess, so I'm sorry.
(What it actually does, you can find here (1.))

If anyone knows where the problem lies, I would really appreciate that.