I've got this code:
from zipfile import ZipFile
...
with ZipFile(flu) as zf:
for file in zf.namelist():
if not file.endswith('.sql'):
continue
with zf.open(file,"r") as f:
...
for row_b in f:
...
I want to use the char ';' as newline separator when opening the zip file, instead of '\n'. In this way I can run the SQL statements included in the zip file also if they are formatted in more than one line.
I find out this documentation and this documentation and it seems that I can specify the newline separator when opening a stream. I cannot understand how to do it when opening a zip file.
There is no option to configure the line ending character for
ZipExtFile(whatzip.open(...)returns).However, you can create your own buffered reader with a simple function:
And you can simply use it as: