Help creating a Lua script

Have a look here:

mavlogdump.py should do what you need. I think you can output multiple formats other than MATLab.

You can also output KML from Mission Planner’s log analysis tool and glean GPS data from that.

Writing a Lua script for this seems a waste of time.