Skip to content

MPI-Dortmund/pyStarDB

Repository files navigation

pipeline status coverage report

pyStarDB

Star file IO package

Basic usage

Import package

from pyStarDB import sp_pystardb as star
import pandas as pd

Read a star file

sfile = star.StarFile(path)
data: pd.DataFrame = sfile[''] # In case the data block has no name (i.e data_) the key for it is empty

Individual columns can be accessed with:

column_data = data["column_name"]

Write a star file

I assume that you have a pandas dataframe data that you want to write to disk:

new_sfile = star.StarFile("new_file.star")
new_sfile.update('block_name', data, loop=True)
new_sfile.write_star_file(overwrite=True)