Questions tagged [loops]

Loops are a type of control flow structure in programming in which a series of statements may be executed repeatedly until some condition is met.

0
votes
0answers
5 views

How to re-run a result back through a loop

I am scheduling medical exams, and need exclude public holidays from the scheduling process. How do reschedule the exams on public holidays to working days? I have written code to schedule medical ...
0
votes
0answers
10 views

Inserting subdirectory name and last modified by as columns in globbed files

I am working on a loop where I glob multiple files in sub-directories and then combine them all in one file and insert modified date, who modified the file, and what subdirectory it came from. ...
-2
votes
0answers
38 views

How to compare objects inside two List's with only one loop? [on hold]

I have two lists of objects with the same type (Transaction), and i need to compare them. My goal is, first of all, compare "id" and secondly, if they matched, check if matches "amount". How can i do ...
1
vote
1answer
30 views

“Is there a faster alternative for this for loop, where I need to multiply each row once with the other rows?”

This for loop takes to long to run is there another alternative? for (i in 1:nrow(petrolStations)) { k<-i+1 if(k<=nrow(petrolStations)) { for(j in k:nrow(petrolStations)) { distancesToStation[i,...
1
vote
2answers
34 views

How to modify this while to work properly?

I have a while loop that searches for a word in a text file. If it's found, I want to print a message. Otherwise, I want to save the input. This is only a part of the function. This loop saves ...
1
vote
1answer
28 views

Subset pandas timeseries dataframe from looping if statement

Please let me know if the title of my problem is accurate - I think I need a looping if statement to solve the problem below - I am a newbie to Python and programming in general, so don't know if the ...
0
votes
0answers
12 views

How to increment in a loop and not restart at 1

I'm trying to copy element from an outside source­ and the source have more than 1 page. Right now, I can copy all the data from the page, but when I switch from page 1 to page 2, it copy all the ...
-2
votes
1answer
23 views

Need same date range for all items in list

I have .......... wlst=['AA','BB'] DATE=pd.date_range(start='01-01-2019', periods = 3, freq = 'MS') ...................................... I need same month range for all items in list'wlst' as ...
0
votes
1answer
15 views

Axes3D.text() Annotate 3D Scatter Plot

Can't get the 3D text working to annotate the scatter plot points. Tried Axes3D.text, plt.text but keep getting 'missing required positional argument 's'. How do you annotate in 3D in a loop? from ...
3
votes
1answer
44 views

How to make function of O(n) that checks for letters (upper& lower) & ()+-*/ to a tail recursion?

I am trying to figure out how do I convert a function I made that checks for the passed string if it only contains letters (lower case or capital) and only these punctuation ()+-*/....to an efficient ...
1
vote
3answers
32 views

How to turn a list of a list of dictionaries into a dataframe via loop

I have a list of a list of dictionaries. I managed to access each list-element within the outer list and convert the dictionary via pandas into a data-frame. I then save the DF and later concat it. ...
0
votes
1answer
18 views

How to iterate over my postlist to display tags from taggit?

I want to iterate over my postlist, to show on click all the posts with the same tag. I want them to display at the index.html . I understand the function, but i don´t know how to implement it into my ...
0
votes
3answers
31 views

Python loop to call different variables

I am trying to create loop in Python to call different variables. example0="result1" example1="result2" example2="result3" example3="result4" example4="result5" for i in range(5): print(example+...
1
vote
4answers
42 views

Populating a dictionary with multiple lines as one string

I have a file with multiple lines in FASTA format, which I want to break up in pieces and populate a dictionary with these pieces. >piece_1 Lorem ipsum dolor sit amet consectetur adipiscing elit. ...
-1
votes
0answers
27 views

Comparing one element to all other elements in an array that fulfill the predicate and then adding similar elements together

I am working on an time-tracking app, I have an array timetracks = timetracksController.getTimetracks() which just returns an array of [Timetrack], the Timetrack type has a property startTime = Date()....
-1
votes
0answers
6 views

How do I add logs to a file automatically in python(Selenium) using loops?

How do I use a loop(preferably for loop) to give value to the message argument to each of the logging level function? The messages are similar. I tried using a list filled with logging level names ...
1
vote
3answers
22 views

Deleting array element in awk while looping through it: always safe?

This is an awk question: I wonder what is the exact semantics of the loop iterator for (k in array): I know we don't have much control on the order in which the array elements are scanned, and yet I ...
0
votes
0answers
31 views

Struggling to update records in a database (Swift 4.2)

I'm new to coding (my way of saying please don't shoot me because I don't know how to solve my issue, I'm learning as fast as I can, I'm reading books, trying out code, doing a course, etc). I'm ...
0
votes
2answers
53 views

How to get all combination of the values from a 2D array's rows with JavaScript?

the 2D array I'm working with have different length for each row, like: var a = [2, 5, -12, 9]; var b = [54.0, 0.3]; var c = ["tree", "sun", "pool"] var all = [a, b, c] Any length of the row might ...
1
vote
1answer
36 views

R creating 5 variables with column name suffix 1 through 5 using loop

I am trying to create an iterative function in R using a loop or array, which will create three variables and three data frames with the same 1-3 suffix. My current code is: function1 <- function(...
0
votes
1answer
47 views

How can I get my loop to iterate through my list?

I'm new to programming and python. I've built a loop that creates a tiled image using one image, and it works great. for left in range(0,iWidth,(logoWidth + xOffset)): for top in range (0,...
1
vote
1answer
16 views

python create dynamically dictionary for constraints in scipy

I am using the scipy.optimize.minimize(...) routine and I need to specify the constraints argument which takes the form: N = 50 cons = ({'type': 'ineq', 'fun': lambda x: x[0]<x[1]}, ...
0
votes
1answer
18 views

How can I standardize binwidth when making multiple ggplot2 with varying y scale?

I have some code to make plots for all of the variables in my data (36) and export them automatically. It works great, but the set binwidth is pretty small. When I try to change the bindwith, it makes ...
-1
votes
3answers
29 views

Cartesian product of two lists in python letters and numbers [duplicate]

current list1 = ['A','B','C'] list2 = [1,2,3] Desired list 3 = [['A', 1], ['A', 2], ['A', 3], ['B', 1], ['B', 2],['B', 3], ['C', 1], ['C', 2], ['C', 3]] What I have tried list3 = [l+str(n) for l ...
0
votes
0answers
15 views

How do I change the order of address properties in every single row of a table that meets a specific criteria (Using Python2.7)

I have a list of addresses in a CSV file that were given the wrong syntax. For example, I have addresses that show "207 County RD" when they should be "County RD 207". Some addresses have 2755 207 ...
-1
votes
0answers
16 views

How to convert the method with for loops to linq

How to convert this method with loops to Linq in c# public void SelectDataTypeByFieldName(string fieldName, string dataType) { var fieldNameRows = Driver.FindElements(...
0
votes
2answers
30 views

JavaScript: Loop through string and return string + 'ay' if string contains vowel in first letter

I am trying to run a function that does pig latin. I'm stuck on one of the first steps. When I set the input argument equal to 'eat' => I want my code to return the string plus 'ay'. Please see ...
0
votes
2answers
23 views

Apply the same operation to multiple DataFrames efficiently

I have two data frames with the same columns, and similar content. I'd like apply the same functions on each, without having to brute force them, or concatenate the dfs. I tried to pass the objects ...
0
votes
1answer
25 views

How do I debug a Python module function conditional on a loop that calls it?

I have a Python module called functions_from_module, with a function called function_inside_module I'd like to debug. In my application, function_inside_module is being used to process some data which ...
2
votes
4answers
61 views

forEach loop doesn't update an Object value

I'm trying to do a single loop and update an object property with each loop value but something unexpected happens: The first console.log prints the day object property updated as expected. The ...
2
votes
2answers
63 views

JavaScript start iterating Map() from specific element/index

I know that elements in a Map can be iterated over, in the order of insertion. Let's assume we have this map: const a = new Map(); a.set('x', 5); a.set('y', 10); a.set('z', 5); And we want to find ...
0
votes
0answers
47 views

For loop only saving last value [on hold]

I'm trying to generate a loop that combines for and if statements to insert rownames and a value in each row of a matrix. The code doesn't shows any output errors, but the unique value of the matrix ...
0
votes
0answers
7 views

in wordpress how to list posts and categories together?

In my site I'm listing all posts according to tags. If a post is in a category I want the category to show instead of the post. But I want each category to show only once for the 1st post in it. I've ...
0
votes
1answer
30 views

How to scrap and index multiple tables from one page in Python?

I'm trying to match the district numbers with community areas in Chicago using the Wikipedia page: https://en.wikipedia.org/wiki/Community_areas_in_Chicago I know how to do it table by table, but I ...
-1
votes
0answers
17 views

Show image from API and if it doe not exist, a fall back image [duplicate]

I'm just learning php and I know this a basic question so apologizes in advance - I'm trying to show a single image for each item in a loop. Metadata is displaying correctly but I'm having a hard time ...
0
votes
1answer
43 views

Is it always possible to transform multiple selects with while loop and variables into a single query without using temp tables in sql?

This problem can be solved with temp table, however, I don't want to use Temp table or var table, this question is mostly for my personal educational purposes. I inherited the following SQL: DECLARE ...
-4
votes
0answers
28 views

i have 1000 keys, i want to build loop search in google [on hold]

i have many numbers and i want to auto pick this number to search on website (it look like www.google.com) https://imgur.com/a/eyQKO71 i want to build system just like this which subject and ...
0
votes
0answers
36 views

PHP get objects based on their array position and a limit

I have an array of objects (generated by TYPO3) which is coming from the variable $times and looks like this: TYPO3\CMS\Extbase\Persistence\Generic\QueryResultprototypeobject (8 items) 0 => ...
1
vote
1answer
34 views

How to add a input program in the form of (A2 5)

I have created a board for a binary puzzle(its random for now but it will make more sense when I add the rules) for now I need to have a way for someone to change a value in the nested lists, this ...
0
votes
0answers
16 views

How to apply loop to the whole column

I have a button that runs on J2 giving the result in K2. What would be the code to have in the same buttun the same operation applyed to J3 into K3 and so on until the system finds an empty box? ...
1
vote
1answer
28 views

Problem with N-repeating a set of commands | Katalon Chrome extension

This works perfectly for a long time in the old Selenium IDE Firefox add-on but it doesn't work properly in the Katalon Chrome extension. Basically, I'm opening a particular link, I'm writing a text ...
-1
votes
0answers
26 views

How to generate text files based on the list items? [on hold]

I want to generate text files based on below list: list1=[[1,2],[2,4],[6,9]] File name must be generated dynamically: itemfirst.txt contains [1,2] itemsecond.txt contains [2,4] itemthird.txt ...
-2
votes
4answers
62 views

Why do we use `i` as the variable to control a Javascript loop? [duplicate]

I always wondered why we use i in Javascript loops couldn't it be any letter? Just wondering why i seems to be the default one. for (i = 0; i < 5; i++) { text += "The number is " + i + "<br&...
4
votes
2answers
77 views

How can I make UI respond to reactive values in for loop?

I'm making a shiny app which reads from a file, does some processing, and produces a table in the UI. The problem is that the file may be very big, and the analysis is slow, so processing the table ...
0
votes
1answer
35 views

Loop command to move multiple files

I have multiple files in a folder (C:\webfix) the folder has 23 items including random files and folders. I have 70+ folders I need to push these files out to. Each folder looks like this: C:\saas\...
0
votes
1answer
70 views

How can I apply multiple conditions to decide what values are written from an array to a target destination?

In an effort to streamline my efforts for a data transfer macro, I have moved to arrays. I have limited experience with them, let alone vba. But I was able to build it, and have it write. The last ...
1
vote
3answers
52 views

compare adjacent rows in R

In my dataframe, I have a column "dates" and I would like for R to walk through each row of dates in a loop to see if the date before or after it is within a 3-14 day range, and if not, it's indexed ...
-3
votes
0answers
32 views

Making a loop for exam scores that ends/breaks when a negative number is inputted [on hold]

I need to make a code for a school Comp. Science project in which exam scores are inputted, and if the score is 90 - 100, it is an A. If it is 80 - 89, it's a B. If it's 70 - 79, it's a C and so on. I ...
-1
votes
1answer
23 views

Finding duplicate data in two different columns in two different excel files vb.net

my code highlights duplicate values within the two columns in two different based on the rows. its somehow unable to find duplicate vales if the column order is changed. suggestions? Public Sub ...
0
votes
0answers
18 views

How to loop function after reweighing dataset efficiently

Sorry for whatever may be unclear. I've been trying to run a loop of a run expectancy function from the baseballr package (https://rdrr.io/github/BillPetti/baseballr/src/R/run_expectancy_code.R) ...