#!/usr/bin/env python3 import soup_strainer ss = soup_strainer.strainer() json_file = input('Enter a JSON database file: ') if(ss.read_database_file(json_file) == -1): print('Terminating execution.') quit() list_of_numbers = ss.find_numbers() #Frequency of Digits selection list_of_counts = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0} for number in list_of_numbers: for char in number: if(char.isdigit()): list_of_counts[int(char)] += 1 list_of_counts = {'Zero': list_of_counts[0], 'One': list_of_counts[1], 'Two': list_of_counts[2], 'Three': list_of_counts[3], 'Four': list_of_counts[4], 'Five': list_of_counts[5], 'Six': list_of_counts[6], 'Seven': list_of_counts[7], 'Eight': list_of_counts[8], 'Nine': list_of_counts[9]} list_of_numbers = ss.string_to_numbers(list_of_numbers) #Frequency of Percent selection list_of_percents = ss.find_numbers_string('percent') list_of_percents = ss.string_to_numbers(list_of_percents) #Frequency of $ selection list_of_dollars = ss.find_numbers_string('$') list_of_dollars = ss.string_to_numbers(list_of_dollars)
#!/usr/bin/env python3 import soup_strainer as ss strainer = ss.strainer() strainer.read_database('test.json') print('Database') print(strainer.database) print('\nAll Digits') print(strainer.find_all_digits()) print('\nPercents') print(strainer.find_all_string('percent')) print('\n$') print(strainer.find_all_string('$')) print('\nmillion & billion') list_million_billion = [] list_million_billion.extend(strainer.find_all_string('million')) list_million_billion.extend(strainer.find_all_string('billion')) print(list_million_billion) print('\nNull String') print(sorted(strainer.find_all_string('')));