Commit fc174ee7 authored by Alan Mitchell's avatar Alan Mitchell
Browse files

Moved import_readings script to App script folder.

parent 45258fad
'''Adds a number of sensors to the system using sensor attributes stored in
a text file.
a text file. This can be less time consuming than using the Admin interface
to add the sensors.
The sensor information must be stored in a text file with the name
'new_sensors.txt' stored in the subdirectory 'files' beneath this script. The
......
"""Script to import a file(s) of sensor readings into the reading database.
The script must be called with one command line argument that gives the file
to import or a glob wildcard spec for a set of files. So, examples of running
to import or a glob wildcard spec for a set of files.
NOTE: unlike other scripts in this directory, this script does **not** use the
django-extensions runscript facility. So, examples of running
the script are:
./import_readings.py readings.txt
./import_readings.py *.txt
You can use the 'files' subdirectory to store import files and instead execute:
./import_readings.py files/readings.txt
The script uses the bmsapp.readingdb.bmsdata.BMSdata.import_text_file() method,
so the text file must comply with the format required by that method, which is:
......@@ -28,10 +33,10 @@ import sys, glob
# Add the parent directory to the Python import path
sys.path.insert(0, '../')
import bmsdata
import readingdb.bmsdata
# Open reading database object
db = bmsdata.BMSdata()
db = readingdb.bmsdata.BMSdata()
for filename in glob.glob(sys.argv[1]):
success_count, errors = db.import_text_file(filename)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment