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

Error in download Function of pysus v0.10.4 with Unpackable File Names #199

Closed
Twetler opened this issue Jul 9, 2024 · 1 comment · Fixed by #200
Closed

Error in download Function of pysus v0.10.4 with Unpackable File Names #199

Twetler opened this issue Jul 9, 2024 · 1 comment · Fixed by #200
Assignees
Labels

Comments

@Twetler
Copy link

Twetler commented Jul 9, 2024

How to reproduce my error

Using version 0.10.4
from pysus.online_data.SIA import download
download('BA', 2024, 4, groups = ["BI"])

image
Which refers to:

def format(self, file: File) -> tuple:
        if file.extension.upper() in [".DBC", ".DBF"]:
            digits = ''.join([d for d in file.name if d.isdigit()])
            print("This",file.name.split(digits))
            chars, _ = file.name.split(digits) # This line crashes
            year, month = digits[:2], digits[2:]
            group, _uf = chars[:-2].upper(), chars[-2:].upper()
            return group, _uf, zfill_year(year), month
        return ()

After receiving lots of values like this ['BIMG', ''] which is easily unpacked, I got a ['BIMG2305_1'] which can't be unpacked as a tuple.

My shortfix was to extract the List's first item [0] however I don't know if this solution can be used for all files. It also raised a doubt if this logic is reproduced in the other libraries.

@fccoelho
Copy link
Collaborator

It seems that now Datasus is splitting the larger files in two for the bigger states: half of the data goes into BIMG2305_1 and the other half into BIMG2305_2 in your example. @luabida can you add a rule to handle this?

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

Successfully merging a pull request may close this issue.

3 participants