loops

Python: Looping through directory and saving each file using filename as data frame name

狂风中的少年 提交于 2020-08-23 03:48:37
问题 In R there is a function called assign which assigns a value to a name in the environment. EG: assign("Hello", 2) > Hello [1] 2 In python I can't seem to do the same. I initially tried: import numpy as np import pandas as pd import os for file in os.listdir('C:\\Users\\Olivia\\Documents'): if file.endswith(".csv"): os.path.splitext(file)[0] = pd.read_csv('C:\\Users\\Olivia\\Documents\\' + file) But I can see this is trying to make a string equal to a file which doesn't work. I managed to get

Python: Looping through directory and saving each file using filename as data frame name

别等时光非礼了梦想. 提交于 2020-08-23 03:48:26
问题 In R there is a function called assign which assigns a value to a name in the environment. EG: assign("Hello", 2) > Hello [1] 2 In python I can't seem to do the same. I initially tried: import numpy as np import pandas as pd import os for file in os.listdir('C:\\Users\\Olivia\\Documents'): if file.endswith(".csv"): os.path.splitext(file)[0] = pd.read_csv('C:\\Users\\Olivia\\Documents\\' + file) But I can see this is trying to make a string equal to a file which doesn't work. I managed to get

Bash Script Loop Through MySQL

天涯浪子 提交于 2020-08-21 05:19:42
问题 I need a bash script that can retrieve MySQL data from a remote data base. Actually I have that done, but what I need it to do now is loop through the records somehow and pass a variable to another bash file. Here's my MySQL call: mysql -X -u $MyUSER -p$MyPASS -h$MyHOST -D$MyDB -e'SELECT `theme_name`, `guid` FROM `themes` WHERE `theme_purchased`="1" AND `theme_compiled`='0';' > themes.xml download_themes.sh It exports the data into an xml file called theme.xml right now, I was just trying to

Why there is no output or blank output for this java code containing “do while” loop? [closed]

有些话、适合烂在心里 提交于 2020-08-20 14:42:41
问题 Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 days ago . Improve this question Can you please explain why there is no output or blank output for the following java code containing do while loop? public class Main { public static void main(String[] args) { int i = 10; do while ( i < 10 ) System.out.print("The value of i is " + i); while ( i

Why there is no output or blank output for this java code containing “do while” loop? [closed]

被刻印的时光 ゝ 提交于 2020-08-20 14:41:33
问题 Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 days ago . Improve this question Can you please explain why there is no output or blank output for the following java code containing do while loop? public class Main { public static void main(String[] args) { int i = 10; do while ( i < 10 ) System.out.print("The value of i is " + i); while ( i

R: How to increment the incrementing variable within a for loop?

老子叫甜甜 提交于 2020-08-11 07:05:11
问题 I'm trying to manually increment the i variable when a condition is met. for(i in 1:x){ if(condition){ i <- i + 2 } } When debugging, the (i<-i+2) line is definitely being run, but i still only increments by 1, instead of 3. (+2 from the line and an additional +1 from the auto increment) How can I increment while I'm within the loop? 回答1: So essentially you want to skip a few loop iterations based on a condition. It's a design choice that's rightfully frowned upon, but if you must, you need

Playing the next video when the first one end with video tag as a playlist

淺唱寂寞╮ 提交于 2020-08-10 19:17:28
问题 Hi I am not that good with javascript I have videos and I want when the first video end to play the next video and so. Here is what I tried. <div id="myvideo" style="width: 100%; height: 400px; overflow: hidden;"> <%= video_tag "men-kicking-punching-fighting-during-combat-sport-karate-simulation_b8ltmb7kqx_1080__D.mp4", muted: 'muted',autoplay: :true ,style: 'display: block; height: 100%; width: 100%; object-fit: cover;', class: "active"%> <%= video_tag "young-woman-dancing-on-the-stairs

Hidden element blocking me from clicking on button

对着背影说爱祢 提交于 2020-08-10 19:16:56
问题 The following code does the following: Accesses a URL with the FIRST date Closes the "Understanding origins" pop-up window by clicking on SKIP Click on the "Download data" button Opens a new tab with the NEXT date closes previous tab (FIRST date URL) TRIES to click on "Download data" again The problem I have is on number 6. It gives me the "element click intercepted" error, and I assume it's because it thinks a NEW "Understanding origins" pop-up window appeared. However, no pop-up window

Hidden element blocking me from clicking on button

老子叫甜甜 提交于 2020-08-10 19:16:31
问题 The following code does the following: Accesses a URL with the FIRST date Closes the "Understanding origins" pop-up window by clicking on SKIP Click on the "Download data" button Opens a new tab with the NEXT date closes previous tab (FIRST date URL) TRIES to click on "Download data" again The problem I have is on number 6. It gives me the "element click intercepted" error, and I assume it's because it thinks a NEW "Understanding origins" pop-up window appeared. However, no pop-up window

Speeding up nested loop comparison

亡梦爱人 提交于 2020-08-10 18:53:47
问题 I have two arrays arr1 and arr2 with sizes (90000,1) and (120000,1) . I'd like to find out if any element of axis=0 of arr1 is present on arr2 . Then write their positions on to a list and later remove them. This will ensure that none of the elements on either lists could be found on the other. For now, I'm using for loops: list_conflict=[] for i in range (len(arr1)): for j in range (len(arr2)): if (arr1[i]==arr2[j]): list_conflict.append([i,j]) fault_index_pos = np.unique([x[0] for x in list