async def init_csv(channel):
fieldnames = ["channel_id", "channel_name", "title", "description", "preview_image", "video", "category", "created_at"]
async with aiofiles.open(f'csv/result-{channel.channel_name}.csv', encoding='utf-8', mode='w') as file:
writer = aiocsv.AsyncDictWriter(file, fieldnames, delimiter=';')
await writer.writeheader()
latin-1 codec cant encode characters in position 11-15: ordinal not in range(256)
PYTHONIOENCODING=utf-8
, но это не помогло.'strict' to raise a ValueError exception if there is an encoding error. The default value of None has the same effect.
'ignore' ignores errors. Note that ignoring encoding errors can lead to data loss.
'replace' causes a replacement marker (such as '?') to be inserted where there is malformed data.
'surrogateescape' will represent any incorrect bytes as low surrogate code units ranging from U+DC80 to U+DCFF. These surrogate code units will then be turned back into the same bytes when the surrogateescape error handler is used when writing data. This is useful for processing files in an unknown encoding.
'xmlcharrefreplace' is only supported when writing to a file. Characters not supported by the encoding are replaced with the appropriate XML character reference &#nnn;.
'backslashreplace' replaces malformed data by Python’s backslashed escape sequences.
'namereplace' (also only supported when writing) replaces unsupported characters with \N{...} escape sequences.