Web Application and Heroku Option
You could create a Web Application, perhaps using the Salesforce Heroku platform to host it, whereby you have a number of languages to choose from. There is a number of toolkits to help utilise the Force API's to access data in Salesforce from such environments, a good starting point Integration Workbook.
Force.com Platform Option
If you want to keep it native this is also possible. It is indeed possible to parse CSV files on the platform there is a number of online resources that provide libraries to do this, though it means you have to get more advanced into Force.com programming and its UI technology known as Visualforce to upload. You will also have to give more consideration to volumes if you handle the CSV loading yourself.
A route worth considering is to utilise as much of the platform tools to get the data into a table (referred to as an Custom Object in Force.com) and then process that using the native Database query and manipulation constructs in the platform via its Apex language. Here is what I would do...
- Create Custom Object that maps precisely the field names of the incoming CSV file. This will help ensure you get the most out of the default mapping in the next step.
- Utilise the one of the Data Loaders on the platform, the latest and most friendly in my view is the Data Import Wizard. After this process this also allows the user via the standard Salesforce UI to review and modify the data if needed before processing.
- Develop a List Custom Button on the Custom Object that invokes some Apex code query the records and process them according to your rules. Clearing the records out when done or leaving records not processed in place for review and retry.
NOTE: If your volumes grow, by the sounds of your logic, you'd probably get several thousand records processed in the interactive Apex context. Beyond that you would have to adapt your logic to Batch Apex, if you study now how that works you can ensure your code is read to work in this environment if you need to scale.