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

Added support for excel #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added support for excel #30

wants to merge 1 commit into from

Conversation

Aderlx
Copy link

@Aderlx Aderlx commented Aug 10, 2018

Hello @vividvilla ,Your project is perfect!,but,I think added support excel maybe better.
so, I use pandas and numpy to read file,As you can see.

def read_file(input_file_name):
    import pandas as pd
    import numpy as np
    suffix = os.path.splitext(input_file_name)[1]
    if not suffix:
        if six.PY2:
            suffix = raw_input('please enter file type.(csv、excel):\t')
        else:
            suffix = input('please enter file type.(csv、excel):\t')
    if 'csv' in suffix:
        df = pd.read_csv(input_file_name)
    else:
        df = pd.read_excel(input_file_name)
    headers = [i for i in df.columns]
    rows = np.array(df).tolist()
    if not headers and len(rows) > 0:
        end = len(headers) + 1
        headers = ["Column {}".format(n) for n in range(1, end)]
    return headers, rows

what are you think?

@chfw
Copy link

chfw commented Aug 19, 2018

an excel variant exists already: https://github.com/pyexcel/excel2table.

@chfw
Copy link

chfw commented Mar 16, 2019

excel2table 2.3.0 is out.

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

Successfully merging this pull request may close these issues.

2 participants