start on register extraction
This commit is contained in:
parent
99ba23e3e6
commit
00bd4ef1f1
1 changed files with 49 additions and 0 deletions
49
tools/create_from_spreadsheet.py
Executable file
49
tools/create_from_spreadsheet.py
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
This is meant to take the fronius provided spreadsheet and munge it into
|
||||
a list of FroniusRegisters and ScaledFroniusRegisters
|
||||
"""
|
||||
|
||||
import pandas
|
||||
import argparse
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="create_from_spreadsheet",
|
||||
description="Generate python registers from the given spreadsheet")
|
||||
|
||||
parser.add_argument('filename')
|
||||
parser.add_argument('-o', '--output')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
input_file = Path(args.filename)
|
||||
|
||||
if args.output is None:
|
||||
output_file = Path(input_file.stem + '.py')
|
||||
else:
|
||||
output_file = Path(args.output)
|
||||
|
||||
input_df = pandas.read_excel(open(input_file, 'rb'), header=0, skiprows=2)
|
||||
|
||||
# Coerce strings to ints so we can sort
|
||||
input_df = input_df[input_df['Start'].apply(lambda x: isinstance(x, (int)))]
|
||||
|
||||
# sort on Start register
|
||||
|
||||
|
||||
print(input_df.columns)
|
||||
print(input_df.sort_values(['Start']))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in a new issue