Skip to content

Commit

Permalink
feat: add excel input option
Browse files Browse the repository at this point in the history
  • Loading branch information
boasvdp committed Dec 17, 2024
1 parent 5887a7c commit b1cbde8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions itolparser/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ def select_input_type(args):
delim = ","
else:
logging.info("No delimiter specified, trying to infer from file extension")
if args.input.suffix == ".tsv":
if args.input.suffix in [".tsv", ".txt"]:
delim = "\t"
elif args.input.suffix == ".csv":
elif args.input.suffix in [".csv"]:
delim = ","
elif args.input.suffix in [".xlsx"]:
delim = "xlsx"
else:
logging.warning(
"Could not infer delimiter from file extension, letting pandas.read_csv guess"
Expand Down
6 changes: 5 additions & 1 deletion itolparser/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import colorbrewer as cb
import pandas as pd
import openpyxl
import numpy as np
import random
from itolparser.version import __version__, __author__, __description__
Expand Down Expand Up @@ -38,7 +39,10 @@ def __init__(

def read_input(self):
"""Read in typing/metadata table using the provided delimiter"""
self.df = pd.read_csv(self.input, sep=self.delim)
if self.delim == "xlsx":
self.df = pd.read_excel(self.input)
else:
self.df = pd.read_csv(self.input, sep=self.delim)

# def make_output_dir(self):
# """Make output directory if it does not exist yet"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
long_description_content_type="text/markdown",
url="https://github.com/boasvdp/itolparser",
packages=setuptools.find_packages(),
install_requires=["colorbrewer", "pandas", "numpy"],
install_requires=["colorbrewer", "pandas", "numpy", "openpyxl"],
python_requires=">=3",
entry_points={
"console_scripts": [
Expand Down

0 comments on commit b1cbde8

Please sign in to comment.