This is very trivial to do for a basic text file or CSV/TSV file but Excel is a proprietary format that requires special modules and much more advanced code (although the modules do most of the hard work for you ). Do a search for python excel and pick the package you want to use and start learning it.