This is a R scrtipt
# load licray
# jsonlite will help you read and parse your JSON data.
# dplyr provides functions to manipulate and summarize the data.
# lubridate helps you handle date and time.
library(jsonlite)
library(dplyr)
library(lubridate)
# it has to be an --jasonArray
data <- fromJSON("car_in_out_car-12-15-24-09-39.json", flatten = TRUE)
# Convert 'inTime' to Date (without time)
data$inDate <- as.Date(data$inTime)
# Summarize by day
summary_by_day <- data %>%
group_by(inDate) %>%
summarize(count = n()) %>%
arrange(inDate)
# View the summary
# print(summary_by_day)
print(summary_by_day, n = nrow(summary_by_day))
Running on this sample jsonArray of a parking lot,
[{"_id":{"$oid":"6715b7bff679da3f6e2a7f26"},"plateText":"BMH5561","inTime":"2024-03-31T21:41:05","outTime":"2024-03-31T23:42:37","carType":"car","inCameraSource":"","isExit":true,"isMonthlyCar":false,"isUserCreate":false,"outCameraSource":""},{"_id":{"$oid":"6715b7bff679da3f6e2a7f29"},"plateText":"RDT3105","inTime":"2024-03-31T21:36:40","outTime":"2024-03-31T23:37:08","carType":"car","inCameraSource":"","isExit":true,"isMonthlyCar":false,"isUserCreate":false,"outCameraSource":""},{"_id":{"$oid":"6715b7c0f679da3f6e2a8059"},"plateText":"BEW8761","inTime":"2024-03-31T19:37:27","outTime":"2024-03-31T21:54:59","carType":"car","inCameraSource":"","isExit":true,"isMonthlyCar":false,"isUserCreate":false,"outCameraSource":""},{"_id":{"$oid":"6715b7c0f679da3f6e2a816a"},
Can the above script could be modified to just print the avrage by Monday, Tuesday, .... Sunday