Fix NaN JSON error.
This commit is contained in:
		
							
								
								
									
										10
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								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.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user