title: How can I pickle a python object into a csv file?
body: <p>I am trying to pickle a python object into a csv file. I want to write the pickle of an object as the third column in my file. I want to use pickle to avoid writing serialization for my complex objects. </p>
  
  <p>Code to write to csv : </p>
  
  <pre><code> with open(self.file_path, 'a') as csv_file:
          wr = csv.writer(csv_file, delimiter='|')
          row = ['klines', symbol]
          row.extend(pickle.dumps(object))
          wr.writerow(row)
  </code></pre>
  
  <p>Code to read csv : </p>
  
  <pre><code> with open(self.simulation_file_name, 'r') as csv_file:
          line = csv_file.readline()
          while line != '':
              line = line.strip('\n')
              columns = line.split('|')
              event_type = line.pop(0)
              symbol = line.pop(0)
              pickled = line.pop(0)
              klines = pickle.loads(klines)
  </code></pre>
  
  <p>I get the following error : </p>
  
  <pre><code>TypeError: a bytes-like object is required, not 'str'
  </code></pre>