I believe a
pandas approach would be fast enough (probably faster than any other Python approach without pandas).
After converting your table to a
pandas data frame, you can do something like
df.filter(regex=(".*Chr01")) for the first chromosome then write the resulting data to file with the
import pandas as pd data = pd.read_csv('input.txt', delimiter = "\t", index_col = False) for i in ["Chr01", "Chr02", "Chr03"]: regex_pattern = ".*" + i print(data.filter(regex=regex_pattern))