Skip to content

Force file_type on read #148

@guysoft

Description

@guysoft

Hey,
So working with files ending with .txt that are actually .csv files.
This is in fact the standard in Example GTFS Feed which are used by google and governments.

So I need a way to read a file ending in .txt as a .csv.

I see here in the code that there is a use of file_type, but it would not work if there is a file_name already defined. Is this a bug or covering a use-case I don't know?
Can I PR something that uses force_file_type or something like that?

class FileSourceInfo(SourceInfo):
    """Plugin description for a file source"""
    def is_my_business(self, action, **keywords):
        status = SourceInfo.is_my_business(self, action, **keywords)
        if status:
            file_name = keywords.get("file_name", None)
            if file_name:
                if is_string(type(file_name)):
                    file_type = find_file_type_from_file_name(file_name,
                                                              action)
                else:
                    raise IOError("Wrong file name")
            else:
                file_type = keywords.get("file_type")

            status = self.can_i_handle(action, file_type)
        return status

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions