Upload files to "grafana-data"
This commit is contained in:
41
grafana-data/grafana-radiation.py
Normal file
41
grafana-data/grafana-radiation.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import csv
|
||||||
|
from rdflib import Graph, URIRef, Literal, Namespace
|
||||||
|
from rdflib.namespace import RDF, RDFS, XSD
|
||||||
|
|
||||||
|
# Define namespaces
|
||||||
|
SINCERE = Namespace("http://sincere.org/s1#")
|
||||||
|
graph = Graph()
|
||||||
|
graph.bind("sincere", SINCERE)
|
||||||
|
graph.bind("xsd", XSD)
|
||||||
|
|
||||||
|
# Create initial triples for the station
|
||||||
|
station_uri = URIRef(SINCERE + "davis2")
|
||||||
|
|
||||||
|
# Read the CSV file and generate barometer triples
|
||||||
|
csv_file = 'solar_radiation.csv' # Replace with your CSV file path
|
||||||
|
with open(csv_file, newline='') as csvfile:
|
||||||
|
reader = csv.DictReader(csvfile)
|
||||||
|
|
||||||
|
# Print the headers to check what's inside
|
||||||
|
print("CSV Headers:", reader.fieldnames)
|
||||||
|
|
||||||
|
for i, row in enumerate(reader, start=1):
|
||||||
|
# Normalize column names by stripping spaces and lowercasing them
|
||||||
|
row = {key.strip().lower(): value.strip() for key, value in row.items()}
|
||||||
|
|
||||||
|
print(row)
|
||||||
|
|
||||||
|
radiation_uri = URIRef(SINCERE + f"davis2/radiation/{i}")
|
||||||
|
|
||||||
|
# Add the barometer triples
|
||||||
|
graph.add((station_uri, SINCERE.hasRadiation, radiation_uri))
|
||||||
|
graph.add((radiation_uri, RDF.type, SINCERE.Radiation))
|
||||||
|
graph.add((radiation_uri, SINCERE.value, Literal(row["solarradiation"], datatype=XSD.integer)))
|
||||||
|
graph.add((radiation_uri, SINCERE.timestamp, Literal(row["ο»ώtime"], datatype=XSD.string)))
|
||||||
|
|
||||||
|
|
||||||
|
# Save the RDF triples to a Turtle file
|
||||||
|
output_file = 'radiation-translated.ttl'
|
||||||
|
graph.serialize(destination=output_file, format='turtle')
|
||||||
|
|
||||||
|
print(f"RDF triples saved to {output_file}")
|
||||||
41
grafana-data/grafana-rain.py
Normal file
41
grafana-data/grafana-rain.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import csv
|
||||||
|
from rdflib import Graph, URIRef, Literal, Namespace
|
||||||
|
from rdflib.namespace import RDF, RDFS, XSD
|
||||||
|
|
||||||
|
# Define namespaces
|
||||||
|
SINCERE = Namespace("http://sincere.org/s1#")
|
||||||
|
graph = Graph()
|
||||||
|
graph.bind("sincere", SINCERE)
|
||||||
|
graph.bind("xsd", XSD)
|
||||||
|
|
||||||
|
# Create initial triples for the station
|
||||||
|
station_uri = URIRef(SINCERE + "davis2")
|
||||||
|
|
||||||
|
# Read the CSV file and generate barometer triples
|
||||||
|
csv_file = 'last15_rain.csv' # Replace with your CSV file path
|
||||||
|
with open(csv_file, newline='') as csvfile:
|
||||||
|
reader = csv.DictReader(csvfile)
|
||||||
|
|
||||||
|
# Print the headers to check what's inside
|
||||||
|
print("CSV Headers:", reader.fieldnames)
|
||||||
|
|
||||||
|
for i, row in enumerate(reader, start=1):
|
||||||
|
# Normalize column names by stripping spaces and lowercasing them
|
||||||
|
row = {key.strip().lower(): value.strip() for key, value in row.items()}
|
||||||
|
|
||||||
|
print(row)
|
||||||
|
|
||||||
|
rain_uri = URIRef(SINCERE + f"davis2/rain/{i}")
|
||||||
|
|
||||||
|
# Add the barometer triples
|
||||||
|
graph.add((station_uri, SINCERE.hasRain, rain_uri))
|
||||||
|
graph.add((rain_uri, RDF.type, SINCERE.Rain))
|
||||||
|
graph.add((rain_uri, SINCERE.value, Literal(row["last15minrain"], datatype=XSD.integer)))
|
||||||
|
graph.add((rain_uri, SINCERE.timestamp, Literal(row["ο»ώtime"], datatype=XSD.string)))
|
||||||
|
|
||||||
|
|
||||||
|
# Save the RDF triples to a Turtle file
|
||||||
|
output_file = 'rain-translated.ttl'
|
||||||
|
graph.serialize(destination=output_file, format='turtle')
|
||||||
|
|
||||||
|
print(f"RDF triples saved to {output_file}")
|
||||||
41
grafana-data/grafana-temperature.py
Normal file
41
grafana-data/grafana-temperature.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import csv
|
||||||
|
from rdflib import Graph, URIRef, Literal, Namespace
|
||||||
|
from rdflib.namespace import RDF, RDFS, XSD
|
||||||
|
|
||||||
|
# Define namespaces
|
||||||
|
SINCERE = Namespace("http://sincere.org/s1#")
|
||||||
|
graph = Graph()
|
||||||
|
graph.bind("sincere", SINCERE)
|
||||||
|
graph.bind("xsd", XSD)
|
||||||
|
|
||||||
|
# Create initial triples for the station
|
||||||
|
station_uri = URIRef(SINCERE + "davis2")
|
||||||
|
|
||||||
|
# Read the CSV file and generate barometer triples
|
||||||
|
csv_file = 'outside_temp.csv' # Replace with your CSV file path
|
||||||
|
with open(csv_file, newline='') as csvfile:
|
||||||
|
reader = csv.DictReader(csvfile)
|
||||||
|
|
||||||
|
# Print the headers to check what's inside
|
||||||
|
print("CSV Headers:", reader.fieldnames)
|
||||||
|
|
||||||
|
for i, row in enumerate(reader, start=1):
|
||||||
|
# Normalize column names by stripping spaces and lowercasing them
|
||||||
|
row = {key.strip().lower(): value.strip() for key, value in row.items()}
|
||||||
|
|
||||||
|
print(row)
|
||||||
|
|
||||||
|
temperature_uri = URIRef(SINCERE + f"davis2/temperature/{i}")
|
||||||
|
|
||||||
|
# Add the barometer triples
|
||||||
|
graph.add((station_uri, SINCERE.hasTemperature, temperature_uri))
|
||||||
|
graph.add((temperature_uri, RDF.type, SINCERE.Temperature))
|
||||||
|
graph.add((temperature_uri, SINCERE.value, Literal(row["outsidetemperature"], datatype=XSD.float)))
|
||||||
|
graph.add((temperature_uri, SINCERE.timestamp, Literal(row["ο»ώtime"], datatype=XSD.string)))
|
||||||
|
|
||||||
|
|
||||||
|
# Save the RDF triples to a Turtle file
|
||||||
|
output_file = 'temperature-translated.ttl'
|
||||||
|
graph.serialize(destination=output_file, format='turtle')
|
||||||
|
|
||||||
|
print(f"RDF triples saved to {output_file}")
|
||||||
41
grafana-data/grafana-wind.py
Normal file
41
grafana-data/grafana-wind.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import csv
|
||||||
|
from rdflib import Graph, URIRef, Literal, Namespace
|
||||||
|
from rdflib.namespace import RDF, RDFS, XSD
|
||||||
|
|
||||||
|
# Define namespaces
|
||||||
|
SINCERE = Namespace("http://sincere.org/s1#")
|
||||||
|
graph = Graph()
|
||||||
|
graph.bind("sincere", SINCERE)
|
||||||
|
graph.bind("xsd", XSD)
|
||||||
|
|
||||||
|
# Create initial triples for the station
|
||||||
|
station_uri = URIRef(SINCERE + "davis2")
|
||||||
|
|
||||||
|
# Read the CSV file and generate barometer triples
|
||||||
|
csv_file = 'wind_spead.csv' # Replace with your CSV file path
|
||||||
|
with open(csv_file, newline='') as csvfile:
|
||||||
|
reader = csv.DictReader(csvfile)
|
||||||
|
|
||||||
|
# Print the headers to check what's inside
|
||||||
|
print("CSV Headers:", reader.fieldnames)
|
||||||
|
|
||||||
|
for i, row in enumerate(reader, start=1):
|
||||||
|
# Normalize column names by stripping spaces and lowercasing them
|
||||||
|
row = {key.strip().lower(): value.strip() for key, value in row.items()}
|
||||||
|
|
||||||
|
print(row)
|
||||||
|
|
||||||
|
wind_uri = URIRef(SINCERE + f"davis2/wind/{i}")
|
||||||
|
|
||||||
|
# Add the barometer triples
|
||||||
|
graph.add((station_uri, SINCERE.hasWindSpeed, wind_uri))
|
||||||
|
graph.add((wind_uri, RDF.type, SINCERE.Wind))
|
||||||
|
graph.add((wind_uri, SINCERE.value, Literal(row["windspeed"], datatype=XSD.integer)))
|
||||||
|
graph.add((wind_uri, SINCERE.timestamp, Literal(row["ο»ώtime"], datatype=XSD.string)))
|
||||||
|
|
||||||
|
|
||||||
|
# Save the RDF triples to a Turtle file
|
||||||
|
output_file = 'wind-translated.ttl'
|
||||||
|
graph.serialize(destination=output_file, format='turtle')
|
||||||
|
|
||||||
|
print(f"RDF triples saved to {output_file}")
|
||||||
80788
grafana-data/last15_rain.csv
Normal file
80788
grafana-data/last15_rain.csv
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user