CSV File Reading & Writing

Loading
loading...

CSV File Reading & Writing

December 29, 2020
[email protected]
No Comments

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)))

University of Washington

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

 

 

 

S. 3209 Campus Fire Safety Education Act of 2020

December 22, 2020
[email protected]
,
No Comments

434 lawmakers, including 89 new freshman Members, were sworn in to the 116th Congress on January 3, 2019. Photo by Phi Nguyen.

A bill to authorize the Secretary of Education to make grants to support fire safety education programs on college campuses.

Fire Standards

December 22, 2020
[email protected]
No Comments

“Great Fire of London”

ASTM International is broadly diversified ANSI accredited standards development organization; one of several non-profit organizations that run close-coupled with US-based nationally-recognized testing laboratories that capture revenue from manufacturers of products.  Interoperability standards – which is our primary focus  — is only one part of ASTM’s business though interoperability is a necessary condition for ASTM’s customers to succeed.  In the fire safety domain we follow best practice coming from this committee:

Committee E05 on Fire Standards

The list in the link indicates contributions to fire safety that perfectly align with education community fire safety.   ASTM titles are found in the informational references of many NFPA codes and standards.    ASTM titles get picked up in our algorithm routinely, though when those titles are released for public consultation they arrive in large batches with the minimum review period.

There are a number of noteworthy titles currently under development; among the following:

E1776-16 Standard Guide for Development of Fire-Risk-Assessment Standards

Committee E05 is also the US Technical Advisory Group Administrator to ISO/TC 21/SC 3 Fire detection and alarm systems.  We are not seeing any action in titles coming from that committee; likely owed to the pandemic.

At the moment Committee E05 has blocked out a face-to-face meeting in June in Toronto.  Contact Thomas O’Toole 610-832-9739 for more information.

We maintain the work of this committee on the standing agenda of our Prometheus Bound colloquia on fire safety.   See our CALENDAR for the next online meeting; open to everyone.

Issue: [9-51]

Category: Fire Safety, Public Safety

Colleagues: Mike Anthony, Marcelo Hirschler,  Joshua W. Elvove, Joe DeRosier, Casey Grant


LEARN MORE:

Fire Safety

online terms and conditions

December 17, 2020
[email protected]

No Comments

This content is accessible to paid subscribers. To view it please enter your password below or send [email protected] a request for subscription details.

S. 253 Streamlining Energy Efficiency for Schools Act

December 15, 2020
[email protected]
No Comments

434 lawmakers, including 89 new freshman Members, were sworn in to the 116th Congress on January 3, 2019. Photo by Phi Nguyen.

A bill to coordinate the provision of energy retrofitting assistance to schools. Introduced January 29, 2019.

AMERICAN ATHLETIC CONFERENCE V. ALSTON

December 14, 2020
[email protected]

No Comments

This content is accessible to paid subscribers. To view it please enter your password below or send [email protected] a request for subscription details.

Uniform Plumbing Code

December 12, 2020
[email protected]

No Comments

This content is accessible to paid subscribers. To view it please enter your password below or send [email protected] a request for subscription details.

Layout mode
Predefined Skins
Custom Colors
Choose your skin color
Patterns Background
Images Background
Skip to content