Python Forum
Trying to sort a MYSQL Database
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to sort a MYSQL Database
#6
No, it will provide a list of all words in most used order. You can match this to your list simply:

untested and unfinished code:
from collections import Counter
...
# If not already a list:
delimiter = '|' # Or whatever it is
data_list = result_details.strip().split(delimiter)
most_common_list = Counter(data_list).most_common()

mc_dict = dict((x, y) for x, y in most_common)

print(mc_dict)
matches = []

for idx, word in enumerate(MC):
    try:
        count = mc_dict[word]
        matches.append(result_id[idx], word, count)
    except:
        continue

print(matches)
matches will contain a list of all your MC entries that were found with corresponding id and a count of the number of times occurred.
Reply


Messages In This Thread
Trying to sort a MYSQL Database - by PierreSoulier - Jul-04-2018, 08:39 AM
RE: Trying to sort a MYSQL Database - by Larz60+ - Jul-04-2018, 08:51 AM
RE: Trying to sort a MYSQL Database - by Larz60+ - Jul-04-2018, 09:20 AM
RE: Trying to sort a MYSQL Database - by Larz60+ - Jul-04-2018, 04:19 PM
RE: Trying to sort a MYSQL Database - by Larz60+ - Jul-05-2018, 10:23 AM
RE: Trying to sort a MYSQL Database - by Larz60+ - Jul-05-2018, 03:38 PM
RE: Trying to sort a MYSQL Database - by Larz60+ - Jul-06-2018, 11:14 AM
RE: Trying to sort a MYSQL Database - by micseydel - Jul-14-2018, 03:19 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mysql and mysql.connector error lostintime 2 693 Oct-03-2023, 10:25 PM
Last Post: lostintime
Photo a.sort() == b.sort() all the time 3lnyn0 1 1,328 Apr-19-2022, 06:50 PM
Last Post: Gribouillis
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,149 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  mySQL Database error not resolving. cybertooth 2 3,235 Aug-30-2021, 05:45 PM
Last Post: ibreeden
  SaltStack: MySQL returner save less data into Database table columns xtc14 2 2,187 Jul-02-2021, 02:19 PM
Last Post: xtc14
  Problem updating value in MySQL database dangermaus33 1 1,646 Nov-24-2020, 08:32 PM
Last Post: dangermaus33
  chatterbot utf-8 errors with mysql database isolatedastronaut 0 1,593 Nov-08-2020, 06:54 AM
Last Post: isolatedastronaut
  MYSQL how to assign a table for each user in my username table database? YoshikageKira 1 2,824 Dec-26-2019, 05:57 AM
Last Post: buran
  How to return value from a stored procedure of a MySQL database? UtiliseIT 0 2,343 Jul-22-2019, 10:14 AM
Last Post: UtiliseIT
  Need help saving data into MySQL database reezalaq 0 2,403 Jun-03-2018, 07:50 PM
Last Post: reezalaq

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020