I wanna help my father, good site for OSX scripting?

in macOS edited January 2014
Hello guys,

My father just showed me this really obnoxious thing he has to do for his work.

So, there's this 2 column-wide excel sheet containing about 2500 number ranges., so column 1 is "from", and column 2 is "to", however, these ranges are not entirely correct. Due to some weird issues in the system, certain numbers have been skipped. This means often 2 ranges actually should be one range, or even more.





This should really be one range.

So, the way I figured is, I export the excel sheet to tab-delimited text, and then, if the 6 first digits of the first number on this line equal the 6 first digits of the first number on the next line, the lines could be "merged".

I know some C and Java and all but I really just have no idea what language to use for this specific problem, how to access the file and handle the "next line" and "tab" stuff, so I was just wondering, where do I start for these kind of issues? I suppose Uni shellscripts are more appropriate than Applescripts, but where do I start looking to learn them?

Or if one of you wizzards could just show me the basic introductory steps on how to open the files and iterate through all the numbers, I'll gladly write the algorithm myself

Many many thanks in advance, this would save my dad at least an entire day of extremely tedious work.


  • Reply 1 of 1
    karl kuehnkarl kuehn Posts: 756member
    I would do this one in python. A start would be something like this (note that this is totally untested, and you need to change "INPUT_FILE_NAME"):


    #!/usr/bin/env python

    minimumGap = 2

    inputFile = open('INPUT_FILE_NAME')

    if inputFile:

    ----lastStartValue = None

    ----lastEndValue = None

    ----for inputLine in inputFile:

    --------startValue, endValue = inputLine.split()

    --------if lastEndValue and lastEndValue + minimumGap <= startValue:

    ------------lastEndValue = endValue


    ------------print lastStartValue + "\" + lastEndValue

    ------------lastStartValue = startValue

    ------------lastEndValue = endValue


    You are going to need to re-format this, the forums are eating the tabs in front of lines, and python absolutely requires them, so I replaced the spaces needed with minus signs. Just replace-all spaces for the minus signs and you should be good.
Sign In or Register to comment.