Fix NaN JSON error.

This commit is contained in:
mattbk 2023-04-05 18:27:14 -05:00
parent d2479746eb
commit b16fb4a630

10
app.py
View File

@ -1,6 +1,7 @@
from flask import Flask from flask import Flask
from flask_restful import Resource, Api, reqparse from flask_restful import Resource, Api, reqparse
import pandas as pd import pandas as pd
import numpy as np
import ast import ast
import kiss import kiss
import glob import glob
@ -22,15 +23,12 @@ class Locations(Resource):
# Read some log files # Read some log files
list_stacked = pd.DataFrame() list_stacked = pd.DataFrame()
file_list = glob.glob("logs/*.log") file_list = glob.glob("logs/*.log")
print(file_list) #print(file_list)
for file in file_list: for file in file_list:
file1 = pd.read_csv(file) file1 = pd.read_csv(file)
list_stacked = pd.concat([list_stacked, file1]) list_stacked = pd.concat([list_stacked, file1])
# TODO Can we do this without numpy?
# TODO get rid of NaN in JSON data? Either blank them or wrap in quotes. list_stacked.replace(np.nan, 0, inplace=True)
# https://jsoneditoronline.org
# SyntaxError: JSON.parse: unexpected character at line 8818 column 20 of the JSON data
# "104": NaN,
# TODO do I need to rearrange the data to a different format? I want all the # TODO do I need to rearrange the data to a different format? I want all the
# data for one packet (one row) together. # data for one packet (one row) together.