Dependence upon software at the foundation of the safety and sustainability agenda of the education facility industry continues to gather pace. The synaptic connections of #SmartCampus infrastructure are hastened by competitive actions of multinational manufacturers with the resources to produce high quality software; perhaps informed by quality benchmarks set by technical committees of ISO/IEC Joint Technical Committee 1. Very often campus-specific adjustments are necessary to install, operate and maintain the software. Many real asset executives managers are faced with the cost of obtaining and retaining expertise to secure their claim to being a #SmartCampus.
Several organizations are active in the open-source software quality space and, as typical for IoT technology, leading practice is determined in real-time. We refer IoT issues, and the real-time commenting opportunities to the IEEE Education & Healthcare Facilities Committee which meets online 4 time monthly in European and American time zones. Today we provide a snapshot of a canonical — i.e. standard — module of code that is present IoT user interfaces.
The Comma Separated Values format is the most common import and export format for spreadsheets and databases. CSV format was used for many years prior to attempts to describe the format in a standardized way in RFC 4180. The lack of a well-defined standard means that subtle differences often exist in the data produced and consumed by different applications. These differences can make it annoying to process CSV files from multiple sources. Still, while the delimiters and quoting characters vary, the overall format is similar enough that it is possible to write a single module which can efficiently manipulate such data, hiding the details of reading and writing the data from the programmer.
The csv module implements classes to read and write tabular data in CSV format. It allows programmers to say, “write this data in the format preferred by Excel,” or “read data from this file which was generated by Excel,” without knowing the precise details of the CSV format used by Excel. Programmers can also describe the CSV formats understood by other applications or define their own special-purpose CSV formats.
The csv module’s reader and writer objects read and write sequences. Programmers can also read and write data in dictionary form using the DictReader and DictWriter classes.
import csv # need to define cmp function in Python 3 def cmp(a, b): return (a > b) - (a < b) # write stocks data as comma-separated values with open('stocks.csv', 'w', newline='') as stocksFileW: writer = csv.writer(stocksFileW) writer.writerows([ ['GOOG', 'Google, Inc.', 505.24, 0.47, 0.09], ['YHOO', 'Yahoo! Inc.', 27.38, 0.33, 1.22], ['CNET', 'CNET Networks, Inc.', 8.62, -0.13, -1.4901] ]) # read stocks data, print status messages with open('stocks.csv', 'r') as stocksFile: stocks = csv.reader(stocksFile) status_labels = {-1: 'down', 0: 'unchanged', 1: 'up'} for ticker, name, price, change, pct in stocks: status = status_labels[cmp(float(change), 0.0)] print ('%s is %s (%.2f)' % (name, status, float(pct)))
Many education industry security, energy and financial enterprises will likely have this standard module of code embedded in it. Python, is one of several programming languages that are best for IoT projects; {C}, Java and Javascript are also common, particularly for moving safety and sustainability content onto the mobile devices of students, faculty and staff.
We maintain IoT software on the standing agenda of our twice monthly Power & ICT teleconferences; open to everyone. See our CALENDAR for the next online meeting. To join us, use the login credentials at the upper right of our home page.
Issue: [Various]
Category: Information & Communication Technology
Colleagues: Mike Anthony, Andrew Green