Open noctorus opened 3 years ago
Eu rodei a rotina para converter o DADOS_ABERTOS_CNPJ_10.zip (referência 23/11/2020) para csv e funcionou corretamente. Eventualmente o arquivo pode estar corrompido? Quando a rotina vai sendo executada, ela apresenta o bloco e a linha, o que ajudaria na hora de debugar.
Baixei recentemente a base, e esta dando o seguinte erro ao executar o arquivo DADOS_ABERTOS_CNPJ_10.zip, os demais exportou sem problemas.
Iniciando processamento em 2021-02-09 09:15:26.677458 Processando arquivo: input/DADOS_ABERTOS_CNPJ_10.zip capital_social <class 'float'>ps:201650|Socios:82612|CNAEs:115738] line_type 1 00000000500000 1 00000001500000 1 00000000500000 1 00000005000000 1 00000000000100 ...
1 00000000000000 1 00000000000000 1 00000001500000 1 00000000500000 1 00000000000100 Name: capital_social, Length: 94446, dtype: object Traceback (most recent call last): File "/media/thiago/THIAGOSTORE/projects/CNPJ-full/cfwf.py", line 103, in _cfwf_chunck data_dict[ltype][col_name] = (data_dict[ltype][col_name] File "/home/thiago/.pyenv/versions/3.8.6/envs/cnpj/lib/python3.8/site-packages/pandas/core/generic.py", line 5874, in astype new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors) File "/home/thiago/.pyenv/versions/3.8.6/envs/cnpj/lib/python3.8/site-packages/pandas/core/internals/managers.py", line 631, in astype return self.apply("astype", dtype=dtype, copy=copy, errors=errors) File "/home/thiago/.pyenv/versions/3.8.6/envs/cnpj/lib/python3.8/site-packages/pandas/core/internals/managers.py", line 427, in apply applied = getattr(b, f)(**kwargs) File "/home/thiago/.pyenv/versions/3.8.6/envs/cnpj/lib/python3.8/site-packages/pandas/core/internals/blocks.py", line 673, in astype values = astype_nansafe(vals1d, dtype, copy=True) File "/home/thiago/.pyenv/versions/3.8.6/envs/cnpj/lib/python3.8/site-packages/pandas/core/dtypes/cast.py", line 1097, in astype_nansafe return arr.astype(dtype, copy=True) ValueError: could not convert string to float: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "cnpj.py", line 463, in
main()
File "cnpj.py", line 455, in main
cnpj_full(input_list, tipo_output, output_path)
File "cnpj.py", line 223, in cnpj_full
for i_bloco, bloco in enumerate(dados):
File "/media/thiago/THIAGOSTORE/projects/CNPJ-full/cfwf.py", line 119, in _cfwf_chunck_reader
yield _cfwf_chunck(chunk, type_width, colspecs, names, dtype)
File "/media/thiago/THIAGOSTORE/projects/CNPJ-full/cfwf.py", line 109, in _cfwf_chunck
raise Exception(e)
Exception: could not convert string to float: ''