У меня большой набор данных, который выдает UnicodeDecodeError
при попытке использовать набор данных.
У меня есть big_file_format_x
и я хочу отформатировать его в big_file_format_y
примерно так:
with open(PATH, "r") as data:
for index, line in enumerate(data.readlines()):
// Formatting logic
with open(SAVE_PATH, "w") as new_data:
new_data.write(formated_data_string)
Затем я разделяю отформатированный набор данных на 3 набора данных:
with open(PATH, "rb") as data:
for line in data.readlines():
// Do splitting logic
with open('train_data.txt', 'wb') as file:
file.write(train_data)
with open('vali_data.txt', 'wb') as file:
file.write(vali_data)
with open('test_data.txt', 'wb') as file:
file.write(test_data)
Теперь, когда я хочу обработать наборы данных, я получаю
kwargs[name] = annotation.from_params(params=subparams, **subextras)
File "/home/public/s1234/.conda/envs/allennlp/lib/python3.6/site-packages/allennlp/common/from_params.py", line 274, in from_params
return subclass.from_params(params=params, **extras)
File "/home/public/s1234/.conda/envs/allennlp/lib/python3.6/site-packages/allennlp/modules/text_field_embedders/basic_text_field_embedder.py", line 136, in from_params
for name, subparams in token_embedder_params.items()
File "/home/public/s1234/.conda/envs/allennlp/lib/python3.6/site-packages/allennlp/modules/text_field_embedders/basic_text_field_embedder.py", line 136, in <dictcomp>
for name, subparams in token_embedder_params.items()
File "/home/public/s1234/.conda/envs/allennlp/lib/python3.6/site-packages/allennlp/common/from_params.py", line 274, in from_params
return subclass.from_params(params=params, **extras)
File "/home/public/s1234/.conda/envs/allennlp/lib/python3.6/site-packages/allennlp/modules/token_embedders/embedding.py", line 200, in from_params
vocab_namespace)
File "/home/public/s1234/.conda/envs/allennlp/lib/python3.6/site-packages/allennlp/modules/token_embedders/embedding.py", line 270, in _read_pretrained_embeddings_file
vocab, namespace)
File "/home/public/s1234/.conda/envs/allennlp/lib/python3.6/site-packages/allennlp/modules/token_embedders/embedding.py", line 293, in _read_embeddings_from_text_file
with EmbeddingsTextFile(file_uri) as embeddings_file:
File "/home/public/s1234/.conda/envs/allennlp/lib/python3.6/site-packages/allennlp/modules/token_embedders/embedding.py", line 450, in __init__
first_line = next(self._handle) # this moves the iterator forward
File "/home/public/s1234/.conda/envs/allennlp/lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 0: invalid start byte
Как мне избежать этой ошибки?