Range Finder: Perl/Python script that takes in a list of integers and automatically groups them into ranges
$30-250 USD
Concluído
Publicado há mais de 9 anos
$30-250 USD
Pago na entrega
The task is to create a command line script that takes an input list containing numbers and it will find ranges for them. Quick example: Input file contains:
56
99
12
5.78
9
43
-22
46
31
68
Range: Count
< 0 : 1
1-10: 2
11-25: 2
26-50: 3
51-75: 2
76-100: 1
Details: The script can handle csv and pipe delimited files and have command line switches for delimiter (-d ',' ) e.g. It can also handle more than one field of integers from the input file: e.g. ( -f 2,7,12) This would mean process fields 2, 7 and 12 and find their ranges.
Range finder can handle negative numbers.
Range finder can accept floating point numbers.
Range finder does not have to handle exotic numbers like pi or e or irrational numbers.
Default behavior is to read in the list of numbers, find the min and max in the list and then design an algorithm that groups the input numbers into 5 ranges as balanced as possible with the values in the input file. In other words, find ranges that contain roughly the same number of values. The default 5 can be changed as a command line switch. (-r 10) e.g. would make the range count equal to 10 and force 10 ranges to be printed (except that no range can have zero values) so if '-r 10' is selected as a command line switch that really means "up to 10 ranges' will be printed.
Another deviation from the default behavior of 5 ranges is that if the total number of unique numbers is less than 5 then count the totals found and print them as the ranges. e.g. The list of number is 10,10,10,10,20,20,20,20,44,44,44 then range finder simply prints the count:
Range: Count:
10: 4
20: 4
44: 3
Ranges are always integers. Values can be floating points, but not the ranges.
If there is only 1 range for negative range and 4 or more positive ranges then the range value of "< 0" is acceptable. And vice versa, if there are only one positive range and 4 or more negative ranges, then "> 0" is an acceptable range.
A command line switch can force a range values to be divisible by 5 or 10 (sometimes it makes formatting look better). Command line switch "-n 5" or "-n 10". In this case, the ranges are forced to be divisible by 5 and 10 on both sides of the range but it still calculates as balanced a count within each range as possible.
All of the default values should be clearly demarcated in functions and can be easily changed by changing a single value in the script. e.g. the default value of 5 ranges should be commented and found at the upper portion of the script.
I look forward to hearing from you.
Hello,
I can accomplish your task in Perl.
This is the command line with the options you specified:
./[login to view URL] -d ',' -f 2,7,12 -r 10 -n 5 <[login to view URL]
The script will implement the requirements as specified assuming the defaults given (unless overridden on the command line).
The first test for the script would be to insure that there was a broad enough range of values to fill each partition; otherwise, counts of each value would be output. But when the ranges exist, the script would use sort to order the values and then splice to generate an (approximately) equal distribution of values. The final function would be to form ranges around various partitions, keeping the restrictions for the -n option (when specified).
Alan Idler
Chief Software Architect
Idleswell Software Creations
$273 USD em 5 dias
4,9 (132 avaliações)
5,8
5,8
2 freelancers estão ofertando em média $220 USD for esse trabalho
Hello,
Greetings from Shweta from Bangalore India.
I have expertise in Perl and have handled many data manipulation scripts in past.
I can have this done in a day.
Please let me know if you have any further information to be shared on this.
I can start work immediately.
Thanks,
Shweta