From b16fb4a630839e5d18d5363f09e2ddf804940127 Mon Sep 17 00:00:00 2001 From: mattbk Date: Wed, 5 Apr 2023 18:27:14 -0500 Subject: [PATCH] Fix NaN JSON error. --- app.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 106f002..56e7d7b 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,7 @@ from flask import Flask from flask_restful import Resource, Api, reqparse import pandas as pd +import numpy as np import ast import kiss import glob @@ -22,15 +23,12 @@ class Locations(Resource): # Read some log files list_stacked = pd.DataFrame() file_list = glob.glob("logs/*.log") -print(file_list) +#print(file_list) for file in file_list: file1 = pd.read_csv(file) list_stacked = pd.concat([list_stacked, file1]) - -# TODO get rid of NaN in JSON data? Either blank them or wrap in quotes. -# https://jsoneditoronline.org -# SyntaxError: JSON.parse: unexpected character at line 8818 column 20 of the JSON data -# "104": NaN, +# TODO Can we do this without numpy? +list_stacked.replace(np.nan, 0, inplace=True) # TODO do I need to rearrange the data to a different format? I want all the # data for one packet (one row) together.