0
votes

I am extracting CSV files from an Excel worksheet using openpyxl in Python 3.4. Since my python version is 3.x, I have to use StringIO instead of BytesIO to make InMemory CSV files.

All is fine and well in Excel to CSV conversion, BUT I am required to send the file object to Vertica copy command cursorV.copy(copy_qry, fileObj).

The command worked fine with BytesIO file object, but with StringIO it gives error:

Can't concat bytes to str

Is there a way to send StringIO file object to vertica copy commmand?

1

1 Answers

0
votes

Fixed it by converting StringIO object to BytesIO using following code:

c = io.BytesIO(a.getvalue().encode())