Update of /cvsroot/webware/Webware/MiscUtils
In directory usw-pr-cvs1:/tmp/cvs-serv24354
Added Files:
CSVJoiner.py
Log Message:
added
--- NEW FILE: CSVJoiner.py ---
import types
def joinCSVFields(fields):
'''
Returns a CSV record (eg a string) from a sequence of fields.
Fields containing commands (,) or double quotes (") are quotes
and double quotes are escaped (""). The terminating newline is
NOT included.
'''
newFields = []
for field in fields:
assert type(field) is types.StringType
if field.find('"')!=-1:
newField = '"' + field.replace('"', '""') + '"'
elif field.find(',')!=-1:
newField = '"' + field + '"'
else:
newField = field
newFields.append(newField)
return ','.join(newFields)
|