for-loop

Simple Perl For-Loop

孤街浪徒 提交于 2020-01-05 09:12:04
问题 I have a for loop and I want to increment the variable by 0.1 each time, however the value changes differently from the increment and I am unsure as to why. I've simplified the for loop and it still gives a strange output: for (my $t = 1000; $t < 1500 ;$t+=0.1) { print "$t\n"; } It prints: 1034.9 1035 1035.1 1035.2 1035.3 1035.4 1035.49999999999 1035.59999999999 1035.69999999999 1035.79999999999 1035.89999999999 1035.99999999999 1036.09999999999 1036.19999999999 1036.29999999999 [it then goes

Find common characters between two strings

大兔子大兔子 提交于 2020-01-05 08:58:08
问题 I am trying to print the common letters from two different user inputs using a for loop . (I need to do it using a for loop.) I am running into two problems: 1. My statement "If char not in output..." is not pulling unique values. 2. The output is giving me a list of individual letters rather than a single string. I tried the split the output but split ran into a type error. wrd = 'one' sec_wrd = 'toe' def unique_letters(x): output =[] for char in x: if char not in output and char != " ":

how to move files to different folders , based on matching filename and foldername in ssis

非 Y 不嫁゛ 提交于 2020-01-05 08:57:32
问题 I have four files xxxxxxCd999, xxxxCf999, xxxxC999 , xxxxD999 ... I need to move these files to their respective folders based on file name , for example file xxxxxCd999 should be moved to folder Cd999 , file xxxxCf999 should be moved to folder Cf999 ,file xxxC999 should ne moved to folder C999 so on ... How do I achieve this in ssis ? I have used a for each loop container, assigned some variables for sourcepath, destinationpath , and a file system task to use these variables , but im lost

How can I get python to read every nth line of a .txt file?

徘徊边缘 提交于 2020-01-05 08:52:52
问题 If I wanted python to read every 2nd (or every 4th) line of a file, how could I tell it to do so? Additionally, if I wanted to read line 2 of a .txt file, but every 4 lines after that (next line would be line 6, then 10, and so on forth), how could I make it do so? 回答1: You can't... [do it using pure I/O functions] You have to read all lines and simply make your code ignore the lines that you do not need. For example: with open(filename) as f: lines = f.readlines() desired_lines = lines[start

Stata: foreach creates too many variables -

时光总嘲笑我的痴心妄想 提交于 2020-01-05 08:14:13
问题 I created a toy example of my code below. In this toy example I would like to create a measure of all higher prices minus lower prices within a self-created reference group. So within each reference group, I would like to take each individual and subtract its price value from all higher price values from other individuals in the same group. I do not want to have negative differences. Then I would like to sum all these differences. In creating this code I found some help here: http://www.stata

JavaScript array 2 dimension for loop

瘦欲@ 提交于 2020-01-05 08:09:31
问题 I want to define a two dimensional array object with for loop... my problem I think my object didn't really get processed, here's the code : var newLoc = []; var index; for (index = 0, i < locations.length; i++){ if(i == 0) { newLoc[i][0] = locations[i][1]; newLoc[i][1] = locations[i][2]; } else { if(locations[i][8] == locations[i-1][8]){ newLoc[i-1][0] = (locations[i][1] + locations[i-1][1])/2; newLoc[i-1][1] = (locations[i][2] + locations[i-2][1])/2; } else{ newLoc[i][0] = locations[i][1];

Optimizing replacement in a data frame

为君一笑 提交于 2020-01-05 07:30:48
问题 This is an extension of Update pairs of columns based on pattern in their names . Thus, this is partially motivated by curiosity and partially for entertainment. While developing an answer to that question, it occurred to me that this may be one of those cases where a for loop is more efficient than an *apply function (and I've been looking for a good illustration of the fact that *apply is not necessarily "more efficient" than a well constructed for loop). So I'd like to pose the question

Incremental countdown to change z-index value of sibling elements

£可爱£侵袭症+ 提交于 2020-01-05 06:44:14
问题 I have checked everywhere looking for a solution to this, and have not been able to figure it out. The solution eludes me. For complicated reasons, I can't simply change the margin/padding swap in CSS, so I'm trying to add style="z-index:5;" in the first div, and then style="z-index:4;" in the second div, etc. so that the last element on the page has the lowest z-index, and each element going toward the top adds one, so it always remains on top if there is any overlap, which is the case with

How to process 2 FOR loops after each other in batch?

南笙酒味 提交于 2020-01-05 05:47:13
问题 My problem is that two FOR loops are working separately, but don't want to work one after another. The goal is: The first loop creates XML files and only when the creation has already been done the second loop starts and counts the size of created XML files and writes it into .txt file. @echo off Setlocal EnableDelayedExpansion for /f %%a in ('dir /b /s C:\Users\NekhayenkoO\test\') do ( echo Verarbeite %%~na jhove -m PDF-hul -h xml -o C:\Users\NekhayenkoO\outputxml\%%~na.xml %%a ) for /f %%i

Place results of predict() in a for loop inside a list

可紊 提交于 2020-01-05 05:43:12
问题 Let us say I want to run the linear regression model on the mtcars dataset several times on different samples. The idea is, for each iteration in a for loop, to store the results of the predict() method every time the linear regression is run for a different sample. The small example follows for one run: ## Perform model once on a Sample and use model on full dataset: Sample_Size <- 10 Sample <- mtcars[sample(nrow(mtcars), Sample_Size), ] Model <- lm(formula = mpg ~ wt, data = Sample)