for-loop

Nested looping with mysqli and fetch_object

帅比萌擦擦* 提交于 2020-01-16 15:43:09
问题 I'm attempting to do a comparision between two tables. If I find a match, I need to copy data from one table and insert it into the other. I'm able to pull the data from the tables just fine, but I'm having issues with a nested loop I created. It only loops through and finds one result. When looking through the tables, there are 1000s of matches, so I assume I'm doing something wrong. My only guess is the use of fetch_object and how I'm using it. I attempted using fetch_assoc instead, but I

Writing a c program to attach a prefix to a list of strings entered

帅比萌擦擦* 提交于 2020-01-16 14:08:08
问题 I'm kind of new to C programming and I'm writing a program to attach a prefix to a list of strings entered by a user. here's a snippet of code. char names[5][20], prefix[5]; int i=0; // accept 5 names and a prefix printf("Please enter the 5 names and a prefix\n"); for(i;i<=4;i++ ) { printf("Enter name %d\n ",i+1); scanf("%s", &names[i]); } printf("prefix: \n "); scanf("%s", &prefix); printf("\n\n\n"); for(i=0;i<=4;i++) { strcat(prefix,names[i]); printf("%s\n", prefix); } My problem is that

running a python file from the ipython notebook using command line in loop

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-16 13:17:19
问题 I have built a model that trains using training.py. I want to tune the hyperparameters and run the following script from the notebook in loop by varying the arguments passed. python training.py --cuda --emsize 1500 --nhid 1500 --dropout 0.65 --epochs 10 For eg: If the hyperparameter is dropout, I want to be able to run the script in loop by varying dropout values and plot the graph. 回答1: You can run a shell command using ! in an ipython environment as !ls -l If you want to use it with

BATCH/CMD: Print each line of a .txt into a variable

China☆狼群 提交于 2020-01-16 12:46:12
问题 Goal: Have every dll file in a computer passed into regsvr32.exe Accomplished: cd\ ::REM Exports every file and directory (/s) into a file in root of c: called dir.txt with only file names (/b) dir /s /b>>dir.txt ::REM Now, this will contain every extension type. We only want dll's, so we findstr it into dll.txt: findstr ".dll$" dir.txt>>dll.txt The Kink: Now, if I want to regsvr32.exe "file" every file that is now in dll.txt, I somehow need to get out every individual filename that is

BATCH/CMD: Print each line of a .txt into a variable

▼魔方 西西 提交于 2020-01-16 12:43:52
问题 Goal: Have every dll file in a computer passed into regsvr32.exe Accomplished: cd\ ::REM Exports every file and directory (/s) into a file in root of c: called dir.txt with only file names (/b) dir /s /b>>dir.txt ::REM Now, this will contain every extension type. We only want dll's, so we findstr it into dll.txt: findstr ".dll$" dir.txt>>dll.txt The Kink: Now, if I want to regsvr32.exe "file" every file that is now in dll.txt, I somehow need to get out every individual filename that is

BATCH/CMD: Print each line of a .txt into a variable

↘锁芯ラ 提交于 2020-01-16 12:43:30
问题 Goal: Have every dll file in a computer passed into regsvr32.exe Accomplished: cd\ ::REM Exports every file and directory (/s) into a file in root of c: called dir.txt with only file names (/b) dir /s /b>>dir.txt ::REM Now, this will contain every extension type. We only want dll's, so we findstr it into dll.txt: findstr ".dll$" dir.txt>>dll.txt The Kink: Now, if I want to regsvr32.exe "file" every file that is now in dll.txt, I somehow need to get out every individual filename that is

Creating R loop to read in shapefiles from a directory and perform zonal statistics on each

自古美人都是妖i 提交于 2020-01-16 09:42:03
问题 I have 120 county shapefiles in a directory "Counties". I want to use R to read in each shapefile and, for each shapefile, perform zonal statistics (mean) using a single raster layer "NOAA_normal_crop." I was able to create a script that reads in all of the shapefiles as a list: library(rgdal) library(raster) library(sf) library(maptools) NOAA_normal <- raster("C:/path/to/raster/noaa_normal.tif") input_path <- "C:/path/to/Counties" files <- list.files(dir, pattern="[.]shp$", full.names=TRUE)

Creating R loop to read in shapefiles from a directory and perform zonal statistics on each

↘锁芯ラ 提交于 2020-01-16 09:41:22
问题 I have 120 county shapefiles in a directory "Counties". I want to use R to read in each shapefile and, for each shapefile, perform zonal statistics (mean) using a single raster layer "NOAA_normal_crop." I was able to create a script that reads in all of the shapefiles as a list: library(rgdal) library(raster) library(sf) library(maptools) NOAA_normal <- raster("C:/path/to/raster/noaa_normal.tif") input_path <- "C:/path/to/Counties" files <- list.files(dir, pattern="[.]shp$", full.names=TRUE)

Creating R loop to read in shapefiles from a directory and perform zonal statistics on each

本小妞迷上赌 提交于 2020-01-16 09:41:09
问题 I have 120 county shapefiles in a directory "Counties". I want to use R to read in each shapefile and, for each shapefile, perform zonal statistics (mean) using a single raster layer "NOAA_normal_crop." I was able to create a script that reads in all of the shapefiles as a list: library(rgdal) library(raster) library(sf) library(maptools) NOAA_normal <- raster("C:/path/to/raster/noaa_normal.tif") input_path <- "C:/path/to/Counties" files <- list.files(dir, pattern="[.]shp$", full.names=TRUE)

Clear memory in python loop

*爱你&永不变心* 提交于 2020-01-16 08:48:30
问题 How i can clear memory in this python loop ? import concurrent.futures as futures with futures.ThreadPoolExecutor(max_workers=100) as executor: fs = [executor.submit(get_data, url) for url in link] for i, f in enumerate(futures.as_completed(fs)): x= (f.result()) results.append(x) del x del f get_data - simple function wich using requests 回答1: My solution would be as such: import concurrent.futures as futures #split the original grand list into smaller batches batchurlList = [grandUrlList[x:x