for-loop

How do I use the FOR batch command to find all text between two specific symbols?

自古美人都是妖i 提交于 2020-01-06 07:44:07
问题 I have a batch script I made to extract chat lines from a log on my gaming server. The input file has text lines like this: 12/30/2015 12:42:03 : #[PLAYERNAME] Hello! I then process each line of the log to extract the player name as follows: for /f "tokens=2 delims=[]" %%d in ("!LINE!") do (set "NAME=%%d") This works fine IF the player has no [] bracket characters in their name. If their name looks like the following: 12/30/2015 12:42:03 : #[<][PLAYERNAME][>] Hello! Or anything similar, then

Loops not working - Strings (Python)

北慕城南 提交于 2020-01-06 07:28:26
问题 I need help in reading these textfiles, somehow when i do a recursive loop, the other loop always gets reset to the 1st line. import sys import codecs # there are actually more utf-8 char to the lines, so i needed codecs reload(sys) sys.setdefaultencoding('utf-8') reader = codecs.open("txtfile1", 'r', 'utf-8') reader2 = codecs.open("txtfile2", 'r', 'utf-8') for row in reader: print row[0:11] # here the outer loops is running the cycles for row2 in reader2: print row[0:11] # here the outer

Can't pass null for argument 'pathString' in child()

好久不见. 提交于 2020-01-06 07:19:11
问题 I'm currently trying to read the contents from my Firebase Database into a RecyclerView but I want to load them from the last node to first node. So I decided to place the keys into an array then try to read from end of the array to the front, but when I try to access the key array I am presented with Can't pass null for argument 'pathString' in child() error. Below is the method I am using to load the data: @Override public void onStart() { super.onStart(); FirebaseRecyclerAdapter

modify php oop mysql query

佐手、 提交于 2020-01-06 07:16:34
问题 Hey, so thanks to the help earlier, I now have a great function for querying a specific row of data. class Posts{ public static function singleQuery($table, $value){ return mysql_fetch_object( mysql_query("select * from $table where id=$value"), __CLASS__); } } $set = Posts::singleQuery('settings', '1'); echo $post->title; I was hoping to modify this so it queries the following: SELECT * FROM posts ORDER BY id DESC LIMIT 0, 3" and then create an 'echo loop' or a foreach type of deal on my

Filtering for rows in a Pandas dataframe containing at least one zero

∥☆過路亽.° 提交于 2020-01-06 07:11:52
问题 I am trying to delete all rows in a Pandas data frame that don't have a zero in either of two columns. My data frame is indexed from 0 to 620. This is my code: for index in range(0, 621): if((zeroes[index,1] != 0) and (zeroes[index,3] != 0)): del(zeroes[index,]) I keep getting a key error. KeyError: (0, 1) My instructor suggested I change the range to test to see if I have bad lines in my data frame. I did. I checked the tail of my dataframe and then changed the range to (616, 621). Then I

Numerical Integration, using the trapezium rule in C

会有一股神秘感。 提交于 2020-01-06 06:56:10
问题 I am using the trapezium rule to calculate the integral of a function between 0 and infinity. I can calculate the value of the integral for a given value of N, and now I am trying to loop N from two to a given value but it will not work. It keeps calculating the value of the integral for when N is 2 and repeating instead of the new value of N. The problem is in the for loop in main() I think. #include <stdio.h> #include <math.h> #include <stdlib.h> #include <float.h> double f(double x) {

How to get Java version in a batch script subroutine?

馋奶兔 提交于 2020-01-06 06:44:54
问题 From this question: for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do ( @echo Output: %%g set JAVAVER=%%g ) How can I put this into a subroutine and call it, passing a path to the java executable? Here's an example of my problem: @echo off setlocal enabledelayedexpansion call :GET_JAVA_VER "java" goto END :GET_JAVA_VER for /f "tokens=3" %%g in ('%1 -version 2^>^&1 ^| findstr /i "version"') do @echo %%g %1 -version 2>&1 | findstr /i "version" goto :EOF :END endlocal

Loop to create PDFs of each node in ego network with node ID as file names in R

允我心安 提交于 2020-01-06 05:57:45
问题 I'm creating ego networks from a graph in iGraph with R, as per the answer that was kindly provided to this question. I then want to export each ego network as a plot in a PDF or image file (preferably PDF). As there are 788 'ego networks' in the full dataframe I'd like to make the file name of the PDF match the relevant node ID for the network i.e. the 'From' column of the dataframe. Otherwise it's too hard to find the particular network that I want. How can this be done? Here's a sample of

Scrapes Emails from a list of URLs saved in CSV - BeautifulSoup

醉酒当歌 提交于 2020-01-06 05:50:09
问题 I am trying to parse thru a list of URLs saved in CSV format to scrape email addresses. However, the below code only managed to fetch email addresses from a single website. Need advice on how to modify the code to loop thru the list and save the outcome (the list of emails) to csv file. import requests import re import csv from bs4 import BeautifulSoup allLinks = [];mails=[] with open(r'url.csv', newline='') as csvfile: urls = csv.reader(csvfile, delimiter=' ', quotechar='|') links = [] for

sql loop and set properties

倖福魔咒の 提交于 2020-01-06 05:36:27
问题 In SQL, I would like to query a list, in order by pageNumber SELECT * FROM `comics` WHERE 1 ORDER BY pageNumber ASC Then, I would like to set their pageNumbers based on their index in the query (starting with 1 instead of 0). Here is my pseudo code for the functionality as desired; where list is the return value of the Select Query above. for(var n:int = 0; n<list.length; n++){ if(list[n].pageNumber != n+1){ list[n].pageNumber = n+1 } } For example I might have pageNumbers 5, 17, 23, 24, 18,