Mercurial > repos > bgruening > flexynesis
diff index_to_name.py @ 5:466b593fd87e draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/flexynesis commit 1afbaf45449e25238935e222f983da62392c067a
author | bgruening |
---|---|
date | Fri, 04 Jul 2025 14:57:40 +0000 |
parents | |
children | 33816f44fc7d |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/index_to_name.py Fri Jul 04 14:57:40 2025 +0000 @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +import sys + +import pandas as pd + + +def get_column_name(file_path, index): + """ + Get the column name based on an index from a tabular file. + """ + data = pd.read_csv(file_path, sep=",") + index = index - 1 # Convert to zero-based index + if index < 0 or index >= len(data.columns): + print(f"Error: Index {index+1} is out of range. File has {len(data.columns)} columns (1-{len(data.columns)}).") + return None + return data.columns[index].strip() + + +if __name__ == "__main__": + + file_path = sys.argv[1] + index = int(sys.argv[2]) + + print(get_column_name(file_path, index))