hq9hrak2f2z7d054c8vwv1zsj6y1
So i try to loop over every line in the text file that has a postfix like 'C' to be sure i get all the line with postfix 'C' and put this line into a variable. But i have no idea how to do this.
I found this : How do I read a file line by line in Python?
But this only reads the whole line into a variable and not every line with postfix 'C'.
Backing up one step: The file that i want to loop over is a sqlite database and the only way i know how to find a postfix 'C' in a line is via the expression 'C'.
For example : " WHERE Id=1";
Thank you in advance for any help on this.
A:
The simple way to do this is:
with open('filename.txt') as f:
for line in f:
if line.startswith('C'):
# do stuff with line
Now I'd suggest to replace line.startswith('C') with line.startswith('C').lower() to lowercase the search term.
The more complicated way would be to load the whole file into a DataFrame and filter on a column:
from pyspark.sql.types import *
df = spark.read.format("csv") \n .options(header="true", delimiter=" ") \n .load("/path/to/data.csv")
df.where('colA = "C"').count() # select from the where column
Q:
How can we add progress updates to tasks in a WebDriver threadpool?
I want to run a function in parallel with a webdriver threadpool in which each function should update a progress bar.
Is there a way to do that?
A:
Instead of doing the heavy action in a thread pool, create a thread to execute your function.
And, create a webdriver thread to perform other actions.
Like this
Thread progressThread = new Thread(new ThreadStart(action));
Thread webDriverThread = new Thread(new WebDriver ac619d1d87
Related links:
Comments