search

Minimise search time for text in a large CSV file

Minimise search time for text in a large CSV file Question: I have a CSV file with about 700 or so rows and 8 columns, the last column however, has a very big block of text (with enough for multiple long paragraphs inside each). I’d like to implement through python a text-search function that gives …

Total answers: 1

Tree Search – given two nodes in a tree, check if they are connected – python

Tree Search – given two nodes in a tree, check if they are connected – python Question: Given a search tree, e.g. “1” └ “2” ├ “2.1” ┊ └ “3” ┊ └ “2.2” └ “2.2.1” └ “3” As well as two nodes, a and b, that belong on that tree, e.g. “2.1” and “3”. How …

Total answers: 3

What's the fastest way to recursively search for files in python?

What's the fastest way to recursively search for files in python? Question: I need to generate a list of files with paths that contain a certain string by recursively searching. I’m doing this currently like this: for i in iglob(starting_directory+’/**/*’, recursive=True): if filemask in i.split(‘\’)[-1]: # ignore directories that contain the filemask filelist.append(i) This works, …

Total answers: 2

Python: check for data type in list

Python: check for data type in list Question: Is there a way to check if an instance of a specific data type is present in a list / dictionary, without explicitly checking every element / key? I suspect the answer is no. If it does exist, though, I imagine it would be similar to the …

Total answers: 3

Flask app search bar

Flask app search bar Question: I am trying to implement a search bar using Flask, but when I enter the url/search, I got a 405 error, Method Not Allowed. Here is a snippet of my code. Any help would be appreciated! forms.py from wtforms import StringField from wtforms.validators import DataRequired class SearchForm(Form): search = StringField(‘search’, …

Total answers: 2

How to search and replace text in an XML file using Python?

How to search and replace text in an XML file using Python? Question: How do I search an entire xml file for a specific text pattern and then replace each occurrence of that text with new text pattern in Python 3.5? Everything else (format, attributes, comments, etc.) needs to remain as it is in the …

Total answers: 3

replace column values in one dataframe by values of another dataframe

replace column values in one dataframe by values of another dataframe Question: I have two dataframes, the first one has 1000 rows and looks like: Date Group Family Bonus 2011-06-09 tri23_1 Laavin 456 2011-07-09 hsgç_T2 Grendy 679 2011-09-10 bbbj-1Y_jn Fantol 431 2011-11-02 hsgç_T2 Gondow 569 The column Group has different values, sometimes repeated, but in …

Total answers: 5

Determining when a column value changes in pandas dataframe

Determining when a column value changes in pandas dataframe Question: I am looking to write a quick script that will run through a csv file with two columns and provide me the rows in which the values in column B switch from one value to another: eg: dataframe: # | A | B –+—–+—– 1 …

Total answers: 3

Python regex search range of numbers

Python regex search range of numbers Question: I couldn’t seem to find a thread on this one, but it seems like something that should be pretty simple. I’m trying to use regex to search a line in an output for a number 0-99, and do one action, but if the number is 100 then it’ll …

Total answers: 3

Find min value in array > 0

Find min value in array > 0 Question: I am looking to find the lowest positive value in an array and its position in the list. If a value within the list is duplicated, only the FIRST instance is of interest. This is what I have which does what I want but includes 0. print …

Total answers: 8