Skip to content

Commit

Permalink
floatify now converts timestamps using datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Zhao authored and asgibson committed Jul 26, 2023
1 parent e1a0831 commit 07d0828
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 75 deletions.
17 changes: 13 additions & 4 deletions data_handling/parsers/parser_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
# Licensed under the NASA Open Source Agreement version 1.3
# See "NOSA GSC-19165-1 OnAIR.pdf"

import ast
import os
from data_handling.parsers.tlm_json_parser import parseTlmConfJson, str2lst
from pandas import to_datetime
import datetime

## Method to extract configuration data and return 3 dictionaries
def extract_configs(configFilePath, configFile, csv = False):
Expand Down Expand Up @@ -56,12 +57,20 @@ def floatify_input(_input, remove_str=False):
floatified.append(x)
except ValueError:
try:
x = i.replace('-', '').replace(':', '').replace('.', '')
floatified.append(float(x))
x = convert_str_to_timestamp(i)
floatified.append(x)
except:
if remove_str == False:
floatified.append(0.0)
else:
continue
continue
return floatified
return floatified

def convert_str_to_timestamp(time_str):
try:
t = to_datetime(time_str)
return t.timestamp()
except:
t = datetime.datetime.strptime(time_str[:24], '%Y-%j-%H:%M:%S.%f')
return t.timestamp()
Loading

0 comments on commit 07d0828

Please sign in to comment.