How to write an import script?
You may use the Operator File Import template which is provided by default.

Open the Text Editor > Templates > Python



I hope, this template would give you good enough starting point and customize it as you go along with your specific needs and requirements.