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
#7
Thank you for the answer :) I think i get your idea.

However result_details is a tuple composed with string of word, each word separated with ' ' (space).
So i don't really understand what you are trying to do on line 5?

Thank you for taking your time to answer :)!

I've tried something like that based on your program:

for text in result_details:
    # If not already a list:
    delimiter = ' ' 
    text=''.join(text) #from tuple to string
    data_list = text.strip().split(delimiter)
    most_common_list = Counter(data_list).most_common(5)
     
    mc_dict = dict((x, y) for x, y in most_common_list)
     
    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)
But this is what i get in return:

{'le': 3, '(jazz': 1, 'de': 6, '\xc3\xa0': 2, 'samedi': 2}
[]
{'vent': 1, '8h': 1, 'de': 4, 'Le': 1, 'plein': 1}
[]
{':': 19, 'Prix': 20, 'du': 12, 'de': 33, '-': 13}
[]
{'ville': 1, 'de': 2, ':': 5, 'pour': 2, 'la': 2}
[]
{'12h': 1, 'et': 3, 'de': 3, 'sur': 3, '\xc3\xa0': 2}
[]
{'\xc3\xa0': 3, 'et': 3, 'de': 6, 'pour': 3, 'les': 5}
[]
{'et': 4, 'de': 6, '\xc3\xa0': 7, 'du': 4, 'la': 7}
[]
{'tir\xc3\xa9': 1, 'port.': 1, 'Feu': 1, 'du': 1, "d'artifice": 1}
[]
{'': 1, 'et': 5, 'au': 2, '18': 2, 'la': 3}
[]
{'et': 2, 'des': 2, 'de': 7, 'le': 2, 'la': 2}
[]
{'60': 1, 'Loto': 1, 'des': 1, '56': 2, '06': 2}
[]
So it seems like the first part is working great but it can't stock data in matches
I've updated the MC list with very common words as 'le','la','et' etc... but i still get matches=[]
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 PierreSoulier - Jul-05-2018, 07:26 AM
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 692 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,138 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  mySQL Database error not resolving. cybertooth 2 3,232 Aug-30-2021, 05:45 PM
Last Post: ibreeden
  SaltStack: MySQL returner save less data into Database table columns xtc14 2 2,183 Jul-02-2021, 02:19 PM
Last Post: xtc14
  Problem updating value in MySQL database dangermaus33 1 1,642 Nov-24-2020, 08:32 PM
Last Post: dangermaus33
  chatterbot utf-8 errors with mysql database isolatedastronaut 0 1,592 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,339 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