Skip to main content
10 votes
Accepted

Python search for array in large text file

Performance It should be possible to accomplish this task in seconds rather than minutes, with the right data structure. This is your main mistake: ...
200_success's user avatar
10 votes
Accepted

Extracting values from dictionaries where the keys match

If I'm understanding it correctly, you're populating a ConcurrentDictionary from the values of two other ConcurrentDictionaries, where the keys are equal. Try this, it's vastly faster than your loop ...
404's user avatar
  • 2,306
8 votes

Extracting values from dictionaries where the keys match

Put simply you change an \$O(1)\$ operation to a \$O(n)\$ one. Dictionary's have \$O(1)\$ key lookup and so if you change your inner loop to, ...
Peilonrayz's user avatar
  • 43.4k
6 votes
Accepted

Joining WorkTypes to WorkGroups via Channels and Users to check authorization

I am understanding that your goal is to return a set of data that a user is authorized to see. I further understand that ChannelUsers and ...
this's user avatar
  • 2,029
6 votes
Accepted

Using LINQ to group social networking links for each user

You could use a Dictionary and make properties of UserViewModel to address elements of this dictionary as follows: ...
Dmitry's user avatar
  • 4,589
5 votes
Accepted

Matching maximal nodes with velocities

Performance Your problem report baffles me. You say that you can successfully produce inputv.dat, a 2.6 GB file, in 45 minutes. Yet, filtering ...
200_success's user avatar
5 votes
Accepted

SQL query to count loans issued during each week

Your query could be simplified. use inner join to avoid ambiguity when reading the query temporal interval join date between start and end (inclusive end) ...
dfhwze's user avatar
  • 13.9k
4 votes

Java8: Stream filter, map and joining with an alternative result if the stream is empty

You can use reduce, it returns an Optional that is empty if the stream is empty. You can use ...
gervais.b's user avatar
  • 2,067
3 votes
Accepted

Filling in gym membership prices by joining PANDAS dataframes

Consider a left side merge to match member data with corresponding prices by contract type and date. No for loops or external list needed for this approach: ...
Parfait's user avatar
  • 960
3 votes
Accepted

Selecting employees in certain departments using LINQ

lstdepartment We don't use Hungarian notation with prefixes like lst in C#. It's just ...
t3chb0t's user avatar
  • 44.3k
3 votes
Accepted

Counting penalties for each player by joining tables, where some of the data is null

You should stay away from pre-ANSI92 join syntax, as it is more error-prone and more difficult to read. It's better to use explicit join syntax in all cases. This join: ...
Phrancis's user avatar
  • 20.4k
3 votes
Accepted

Load title from database based on member country

Formatting Your code has some formatting issues, reducing the readability of it: spacing: your spacing around = seems arbitrary and you are missing spaces around <...
tim's user avatar
  • 25.1k
3 votes

Java8: Stream filter, map and joining with an alternative result if the stream is empty

If you want to still rely on Collectors.joining (and not implement that logic yourself), you can simply add a ...
Eran's user avatar
  • 331
3 votes
Accepted

Joining tables by skipping the intermediate parent table

Your changes to the query are good changes. Just because the both adm_app and quals_data have the same child relationship to ...
rolfl's user avatar
  • 97.4k
3 votes
Accepted

Conditional joining Pandas dataframes

This is the textbook example of an inner join. The most canonical way to have your id columns being used for the matching, set them as an index first (here using <...
ojdo's user avatar
  • 420
3 votes
Accepted

Listing people with their phone numbers (if any)

What you are describing is known asLEFT OUTER JOIN ...
Charles's user avatar
  • 171
3 votes
Accepted

Python script to find employees who are in one PostgreSQL table but not in another

LEFT JOIN from test_test to test_table selecting only rows where test_table.test_emp_id is <...
Jono Brogan's user avatar
3 votes
Accepted

Join and pivot multiple tables of securities data in MySQL

DB Design Your tables are not correctly normalized: codes.description depends on codes.code → requires a table with ...
dfhwze's user avatar
  • 13.9k
3 votes
Accepted

Update join table using list of checkboxes in Rails

Actually, Active Record can work with joined collection (including has_many :through) from the box. So, you just need to pass new collection instead of old, and AR will delete excessive and add new ...
mikdiet's user avatar
  • 301
2 votes

Matching maximal nodes with velocities

First, some PEP8 style issues and general coding style advices: You shouldn't import modules that you're not using (import time and ...
Grajdeanu Alex's user avatar
2 votes

Gather information about computers from multiple CSV files

Currently your code recreates $Final array in each iteration, scans each of the CSV files entirely in each iteration for each field using ...
woxxom's user avatar
  • 1,952
2 votes
Accepted

Cross context joins in .NET

You can get the results with a single query like this one: ...
t3chb0t's user avatar
  • 44.3k
2 votes
Accepted

Rails query for all questions in tournaments that a user participates in

Ok, so based on what your said your associations are you can do ...
j-dexx's user avatar
  • 136
2 votes

Joining a product-application-customer relationship using Java 8 Streams

Using the appropriate types Your are repeatedly casting searchResult into a Map, the first suggestion I will make is to cast it ...
h.j.k.'s user avatar
  • 19.2k
2 votes

Loading objects for users, roles, and groups from a query with LEFT OUTER JOINs

For the exact case you posted here, I would suggest to use group_concat() in the query. It will dramatically reduce the amount of code required, as well as the amount of data delivered from database. ...
Your Common Sense's user avatar
2 votes

Linking two databases based on street addresses

All you need to do is: normalize the two files, so that the content is in the same format (that means removing whatever you think should not be there, like , <...
ChatterOne's user avatar
  • 2,805
2 votes

SQL-style join on arrays using ECMA6

Build an index and use it to map the second array: ...
woxxom's user avatar
  • 1,952
2 votes

Mapping key value pairs between two JavaScript objects

It might be a little cleaner to use .reduce instead of for...of... loop: ...
Alex.S's user avatar
  • 159
2 votes

Comparing data in SQL using foreign keys

Just think simple: ...
Badaro's user avatar
  • 121
2 votes
Accepted

Project management query for various organizational units

I'd use common table expressions (CTE) for COSTS, EXPENSES and DURATIONS tables. In the CTE, ...
aduguid's user avatar
  • 490

Only top scored, non community-wiki answers of a minimum length are eligible