How to run a SQL query on an Excel table?

There are many fine ways to get this done, which others have already suggestioned. Following along the “get Excel data via SQL track”, here are some pointers. Excel has the “Data Connection Wizard” which allows you to import or link from another data source or even within the very same Excel file. As part of … Read more

Filter multidimensional array based on partial match of search value

Use array_filter. You can provide a callback which decides which elements remain in the array and which should be removed. (A return value of false from the callback indicates that the given element should be removed.) Something like this: $search_text=”Bread”; array_filter($array, function($el) use ($search_text) { return ( strpos($el[‘text’], $search_text) !== false ); }); For more … Read more

Filtering collections in C#

If you’re using C# 3.0 you can use linq, which is way better and way more elegant: List<int> myList = GetListOfIntsFromSomewhere(); // This will filter ints that are not > 7 out of the list; Where returns an // IEnumerable<T>, so call ToList to convert back to a List<T>. List<int> filteredList = myList.Where(x => x … Read more

Filter/Remove rows where column value is found more than once in a multidimensional array

For a clearer “minimal, complete, verifiable example”, I’ll use the following input array in my demos: $array = [ [‘user_id’ => 82, ‘ac_type’ => 1], [‘user_id’ => 80, ‘ac_type’ => 5], [‘user_id’ => 76, ‘ac_type’ => 1], [‘user_id’ => 82, ‘ac_type’ => 2], [‘user_id’ => 80, ‘ac_type’ => 5] ]; // elements [0] and [3] … Read more

Creating a blurring overlay view

You can use UIVisualEffectView to achieve this effect. This is a native API that has been fine-tuned for performance and great battery life, plus it’s easy to implement. Swift: //only apply the blur if the user hasn’t disabled transparency effects if !UIAccessibility.isReduceTransparencyEnabled { view.backgroundColor = .clear let blurEffect = UIBlurEffect(style: .dark) let blurEffectView = UIVisualEffectView(effect: … Read more

Filtering Pandas DataFrames on dates

If date column is the index, then use .loc for label based indexing or .iloc for positional indexing. For example: df.loc[‘2014-01-01′:’2014-02-01′] See details here http://pandas.pydata.org/pandas-docs/stable/dsintro.html#indexing-selection If the column is not the index you have two choices: Make it the index (either temporarily or permanently if it’s time-series data) df[(df[‘date’] > ‘2013-01-01’) & (df[‘date’] < ‘2013-02-01’)] … Read more