Skip to content

Commit

Permalink
First attempt at formatting fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Sep 29, 2023
1 parent 30baf9e commit aa10768
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions stellarphot/io/aavso.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,18 @@ def to_table(self):
value = getattr(self, key.lower())
table.meta['comments'].append(f"{key}={value}")

# Specify formats for the columns that have formats
for k, v in table_structure['data'].items():
length_limit = v.get('limit', None)
if length_limit:
if v['type'] == 'float':
table[k].info.format = f"{length_limit}f"
elif v['type'] == 'str':
if k == 'STARID':
print(table[k])
table[k].info.format = f".{length_limit}s"
else:
raise ValueError(f"Unknown type {v['type']}")
return table

def write(self, filename, overwrite=False):
Expand Down

0 comments on commit aa10768

Please sign in to comment.