Documents and experiments prove that only single-character delimiters are allowed.
Since cvs.reader accepts any object that supports the iterator protocol, you can use the generator syntax to replace || -s | -s, and then pass this generator to the reader:
def read_this_funky_csv(source): # be sure to pass a source object that supports # iteration (eg a file object, or a list of csv text lines) return csv.reader((line.replace('||', '|') for line in source), delimiter='|')
This code is pretty efficient as it runs on the same CSV line at a time if your CSV source gives lines that do not exceed your RAM :)
source share