What I'm wondering is how can I make this program run directly on the stream instead of first having the server write to a tmp file then running this script on that file then writing out a csv file for insertion into a database?
Make the program read from the server, use IO::Socket