This is not a Cisco question, it is a question about MRTG. The home page for MRTG is https://oss.oetiker.ch/mrtg. To answer your question, the text files already exist. Go to the directory where the MRTG stuff is displayed on your web server. For example if you go to http://webserver/mrtg, go to $DOCROOT/mrtg. There are files ending in .log for each graph/interface. The format of the file is documented here: https://oss.oetiker.ch/mrtg/doc/mrtg-logfile.en.html.
MRTG is typically updated via a cron job. It polls the device, appends the data to the .log file and then creates a new PNG file for display on the web server. By default, the cron entry is kicked off every 5 minutes. It also puts an entry in the index.html to reload the web page every 5 minutes.