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

Force file_type on read #148

guysoft opened this issue Aug 3, 2018 · 1 comment

Force file_type on read #148

guysoft opened this issue Aug 3, 2018 · 1 comment


Copy link

guysoft commented Aug 3, 2018

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,
                    raise IOError("Wrong file name")
                file_type = keywords.get("file_type")

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

chfw commented Aug 3, 2018

I acknowledge that this is a valid constraint. for physical file, the only way to tell pyexcel about the file format is the file extension.

A change in pyexcel_io may be required to support this feature. You can submit a PR too. We can work on it together.

chfw added a commit that referenced this issue Aug 22, 2018
chfw added a commit to pyexcel/pyexcel-io that referenced this issue Aug 23, 2018
…en will selects a particular reader. for example: force txt file as csv. But forcing xls as xlsx may not give you any benefit, because pyexcel-xls reads both xls and xlsx. related to: pyexcel/pyexcel#148
chfw added a commit that referenced this issue Aug 23, 2018
…pe togather with file_name. but if you use pyexcel-io, you need to use force_file_type for the same feature
chfw added a commit that referenced this issue Aug 23, 2018
@chfw chfw closed this as completed Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants