Questions tagged [iteration]

Successive repetitions in programming loops, such as 'for', 'foreach', or 'while', are referred to as iterations. Queries tagged with this label frequently revolve around the optimal management of data collections.

Updating values within a column by finding a corresponding match

I am dealing with a Pandas DataFrame that includes the names of Brazilian universities, which can sometimes be listed in both short and long forms (e.g., Universidade Federal do Rio de Janeiro may also appear as UFRJ). Here is an example of how the DataFra ...

Maintaining the order of the returned values type is crucial when working with mapped objects in Typescript

Currently, I am developing a basic mapper function for objects. This function is designed to take an array of object properties and then return an array containing the corresponding values of these properties. The function works as intended; however, I hav ...

String iteration with Stylus

Is there a way to remove the brackets and the quotation marks when putting media queries into an object and looping over them? The code works well, but the stylus is causing the output to have unwanted characters. Here's my code: $maxBreakpoints = { ...

A guide on accessing the first element in an array when performing multiplication within the Interval component in React.js

I am having trouble initiating an if statement from number 0 once the window is loaded, as it seems to be skipping over 0 and starting from 1 instead. Can someone please assist me in understanding how this works? showAnime = () => { let counter ...

Exploring ways to conduct a thorough scan of object values, inclusive of nested arrays

My goal is to extract all values from an object. This object also includes arrays, and those arrays contain objects that in turn can have arrays. function iterate(obj) { Object.keys(obj).forEach(key => { console.log(`key: ${key}, value: ${o ...

Explore the properties within an array of objects through iteration

Here is the array I'm working with: const myArray = [{ id: 1, isSet: true }, { id: 2, isSet: false }, ...]; I only need to iterate over the isSet properties of the objects, ignoring all other properties. Initially, I attempted the following solution: le ...

Passing onClick event to parent component during iteration in ReactJS

I am facing a challenge where I need to remove a row from a table upon a click event. I have managed to create an iteration and display a delete button, but I am struggling with passing the onClick event from the parent component to the child component in ...

Utilize ramda.js to pair an identifier key with values from a nested array of objects

I am currently working on a task that involves manipulating an array of nested objects and arrays to calculate a total score for each identifier and store it in a new object. The JSON data I have is structured as follows: { "AllData" : [ { "c ...

Efficient method for iterating through three arrays that have matching values and satisfy specified conditions in TypeScript

Struggling to speed up my Excel sheet creation time, currently taking over 20 seconds. I'm using the code below to compare three arrays and get the desired output: for (let i = 0; i < this.arrayNumberOne[0].length; i++) { let orangeOne = this.a ...

Using an integer variable to iterate a string within a function in Python

Being a complete novice, I've tried delving into several related topics but I just can't seem to grasp it. My goal is to write a function that will iterate through the string s exactly "n" times. s="hello" n=2 When I use s[::n] it works fine ...

Iterating through a list in Python to check if an item exists in a line

I need to iterate through two lists and only print an item if it is present in the second list. However, I am working with very large files and do not want to load them into memory as a list or dictionary. Is there a method to achieve this without storing ...

Modifying values within inner dictionaries based on certain conditions in Python

I have dictionaries within a dictionary and I need to replace any instances where the value of inner dictionaries is None with the string 'None' so that it will display in a CSV file without appearing as a blank cell. Here's an example: {Object1 : {celll ...

Loop through a collection of arrays that contain the same elements, and multiply each consecutive element by a specified value x

I've been diving into a challenging problem involving remarkable numbers, which are defined as A number that is equal to the sum of all its proper divisors -- provided one of them is negative. For instance, the proper divisors of 12 are 1, 2, 3, 4, 6, add ...

Python guide to cycling through a list and merging certain elements?

Consider a scenario where we have a specific list l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ...]. The objective is to group elements from this list as follows: (1, 5, 9) (2, 6, 10) (3, 7, 11) (4, 8, 12) This grouping pattern should continue considering ...

What could be causing my for loop to not function properly within the ngOnInit lifecycle hook?

I am attempting to create a nested loop structure in order to access an array that is inside an object within an array of objects, and then store this data into a new array. My issue arises as the first loop executes successfully but the second one does no ...

Tips for decoding and processing multiple JSON objects returned from an AJAX call within the initComponent method of a Sencha Touch panel

Looking for a more efficient way to read multiple JSON objects from an AJAX request. The current code provided below is taking too long, causing other codes to execute before this one. var allVisitStore = new Ext.data.Store({ model: 'allVisit', autoLoa ...

Count the number of times an iteration occurs in AngularJS/JavaScript

I need assistance with my code snippet below, as I am trying to determine the count of all instances where $scope.rm is equal to "failed" or when $scope.percentage is less than 50. angular.forEach(result1, function (value, key) { $scope.percentage ...

Locating specific phrases within a vast text document using Python

The code below represents the program I have written: with open("WinUpdates.txt") as f: data=[] for elem in f: data.append(elem) with open("checked.txt", "w") as f: check=True for item in data: if "KB2982791" in item: ...

Struggling to traverse through intricate layers of nested objects in React and showcasing them without going crazy

Dealing with an API that returns data structured in deeply nested objects has been a challenging task. The goal is to extract specific data from these nested objects and then display them within a React project. Despite numerous attempts, finding a simple ...

How to retrieve an anchor element from a list using JavaScript

My current code loops through each <li> within a <td> cell and adds a class to the <li>. I have now inserted <a> tags between each <li> and am facing challenges in accessing the <a> tags. What I actually want is to assig ...

Collect all wallet objects and store them in an array of objects within BitGO for Bitcoin

My Setup: Using the Mongoose module to handle all MongoDB operations, we generate and store a wallet inside a Mongo collection for each new user. METHOD: By using User.find({}, function(err, docs) {, we can retrieve each user object. User.find({}, functi ...

Traversing through objects in react.js

Hello there, I'm currently learning React and JavaScript but facing some challenges with a particular task. Let's dive into it! So, imagine I have an array like this: clients = ["Alex", "Jimmy"] and then I proceed to create another array using th ...

Creating a dropdown menu by specifying specific names within an object

I am in the process of setting up a dropdown menu for all 50 states using an object that contains state names as attributes. Here's an example: window.LGMaps.maps.usa = { "paths": [ { "enable": true, "name": "Alabama", ...

Implementing various event listeners for asynchronous JavaScript and XML requests (

Struggling to iterate through an ajax query and encountering a problem where the i value always defaults to 1. I'm not very well-versed in js so any suggestions on how to tackle this issue or possibly a better approach would be greatly appreciated. Th ...

Include an additional value to the existing array

Here is the code snippet I am working with: $result = array(); $category_name = array(); foreach($category as $cat) { $category_name[] = $cat->category_name; // This value needs to be added to the result array $campaigns = $cat-> ...

python list iteration

I am facing an issue while trying to iterate over the items in a list. The iterator seems to be skipping some objects. Below is the function code that I am using (where dirs and root are obtained from os.walk): def remove_hidden_dirs(dirs,root): """ ...

Is it possible to simultaneously verify if an array is empty within an Object along with checking the other fields?

Let's say I have an object that has the following structure: filter: { masterName: '', service:[], } What is the best way to determine if both the array and masterName field are empty? ...

Can the function variables be dynamically updated with each call?

I am currently tackling an Ordinary Differential Equation (ODE) system using the solve_ivp function and I aim to modify the local variables within the function each time it is called by the solver. Specifically, I wish to update the Lagrange multipliers ...

Exploring the depths of JSON nested maps in Groovy: a step-by-step guide

I have received the following JSON output from AWS DynamoDB and I am looking to loop through it in order to populate a table within Jenkins Parameters using a Groovy script. Is this achievable? JSON: [ { "test": { "S ...

CSV: Determining the frequency of a specific string in a column based on the value in another column

I'm struggling with extracting specific information from a CSV file. Here is the structure of the data: bla country bla bla value Germany Y Germany Y Germany N Denmark N Denm ...

Reorganizing divisions with Dojo

I came across a thread on StackOverflow that was similar to what I'm looking for. jQuery removing an element and renumbering remaining elements However, since we don't use jQuery but instead rely on Dojo, I'm unsure how to achieve the same ...

Loop through the properties of a JsonObject

My goal is to use Gson to iterate through the large wrapping JsonObject. I want to extract an ArrayList containing all three-digit code integers from the inner "unterfeld" objects. This should be straightforward once I can successfully iterate through the ...

What is the best way to unbox nested tuples in python?

Let's imagine there are two users named Peter and Emma who want to place orders for fruits, including bananas and strawberries, in the quantity they desire. Below is the implementation I have created using Python: orders = (('Peter', ((&ap ...

The order of iteration in Python for sets

Currently, I am analyzing two large files (in the order of Gigabytes), each containing a set of keys and their corresponding values. There are some overlapping keys between the two files, but with different corresponding values. My objective is to create n ...

Using Python with Selenium, automate the process of clicking on each list item within

Hey there! I recently implemented the code below, and it worked perfectly. However, I'm now trying to figure out how to make it click on all the li items within a ul that have an empty class attribute. Any ideas on how to do this using Xpath? Xpath: ('// ...