Robert Rawlins - Think Blue wrote: > I have a python application that hits a web service on a regular basis to > post a string of CSV log data and I'm looking to minimize the amount of > bandwidth that the application uses to send the log data. > > Is there any way to encode the string into base64 or something, that I can > then post and decode at the other end? Is that likely to save me bandwidth > perhaps? I don't really know much about this encoding stuff, but the smaller > I can compress the string the better.
You could zip the csv data up first (assuming you control both ends of the conversation). Obviously compression ratios depend on various things. <code> import zlib data = """ BAN X08 001 / 00 01 BAN X08 004 / 00 04 BAN X08 013 / 00 01 BAN X08 016 / 00 01 BAN X08 017 / 00 02 BAN X08 018 / 00 03 BAN X08 010 / 00 01 BAN X08 019 / 00 01 BAN X08 022 / 00 01 BAN X08 025 / 00 01 MAI X01 001 / 00 01 MAI X01 002 / 00 01 MAI X01 003 / 00 01 MAI X01 004 / 00 01 MAI X01 005 / 00 01 MAI X01 006 / 00 01 MAI X01 008 / 00 01 MAI X01 009 / 00 01 MAI X01 010 / 00 01 MAI X01 011 / 00 01 MAI X01 012 / 00 01 MAI X01 013 / 00 01 TOW P02 015 / 00 01 BET C01 006 / 00 BL BET C01 006 / 00 TL BET T01 011 / 00 01 BET T01 012 / 02 01 BET P01 010 / 00 01 BET P01 030 / 00 01 BET P02 022 / 00 01 STO C02 031 / 00 01 BON P01 003 / 01 01 """ compressed_data = zlib.compress (data, 9) print len (data), len (compressed_data) </code> TJG -- http://mail.python.org/mailman/listinfo/python-list