Posts

Showing posts from December, 2018

CSV Reading/Writing

We have recently finished coding the Python (used for writing to the CSV files) and jQuery (used to read them), and the code is available on GitHub . However, I include it here for convenience: Outlets: import socket import sys message = raw_input("Enter your message:") # Read message to be sent # Create a UDP socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) server_address = ('192.168.0.18', 6401) # Server's IP Adress and Port Number for Communication. try: # Send data print (sys.stderr, 'sending "%s"' % message) # Print the message to be sent. sent = sock.sendto(message.encode('utf-8'), server_address) # Send the message # Receive response print (sys.stderr, 'waiting to receive') # Listen for acknowlegement of file receival data, server = sock.recvfrom(4096) # Receive acknowledgement data print (sys.stderr, 'received "%s"' % data) #Print acknowledgement data fi

Move From XML To CSV

Recently, we were discussing our file structure and realised that XML files are unnecessarily complex - we were using the following structure: <livehousewaterusage> <appliance> <appname>sink</appname> <room>kitchen</room> <rate>55</rate> </appliance> <appliance> <appname>sink</appname> <room>bathroom</room> <rate>75</rate> </appliance> <appliance> <appname>toilet</appname> <room>bathroom</room> <rate>85</rate> </appliance> <appliance> <appname>bath</appname> <room>bathroom</room> <rate>80</rate> </appliance> <appliance> <appname>shower</appname> <room>bathroom</room> <rate>100</rate> </appliance> <appliance> <appname>shower</appname> <room>bathroom</room> <rate>