Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erro em conversão float #49

Open
noctorus opened this issue Feb 9, 2021 · 1 comment
Open

Erro em conversão float #49

noctorus opened this issue Feb 9, 2021 · 1 comment

Comments

@noctorus
Copy link

noctorus commented Feb 9, 2021

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: ''

@rictom
Copy link

rictom commented Feb 10, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants