Skip to content

Instantly share code, notes, and snippets.

View nipunbatra's full-sized avatar

Nipun Batra nipunbatra

View GitHub Profile
def create_header_row(parameter_numbers, parameter_list):
'''This function creates the header for a CSV file.
The putput of this function should be appended to a CSV file upon creation
Input:
------
Parameter List: A Python list consisting of strings corresponding to all electrical parameters provided by the smart meter
Parameter Numbers: A Python list corresponding to chosen parameters (to be logged to CSV)
Output:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from configuration import THRESHOLD_TIME, DATA_BASE_PATH, BASE_UPLOAD_PATH
from dbupload import DropboxConnection
import db_password
import glob
import os
import time
import requests
email=db_password.email
password=db_password.password
#First on Linux shell figure if the USB-serial convertor has been detected.
# Type dmesg|grep tty and you should probably see the convertor and the tty USB port it is allocated. I shall assume you got #/dev/ttyUSB0
import serial,time
serial_port=serial.Serial('/dev/ttyUSB0')
file_pointer=open('data.csv','wb')
while True:
a=s.readline()
f.write(str(time.time.now())+","+a)
#!/usr/bin/env python2.7
# script by Alex Eames http://RasPi.tv/
# http://raspi.tv/2013/how-to-use-interrupts-with-python-on-the-raspberry-pi-and-rpi-gpio
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
import time
# GPIO 23 set up as input. It is pulled up to stop false signals
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(23,GPIO.OUT)
@nipunbatra
nipunbatra / pandas_epoch
Last active December 18, 2015 02:58
This IPython notebook illustrates handling epoch timestamps in Pandas
{
"metadata": {
"name": "pandas_epoch"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
import web
import numpy as np
import time
urls = ("/*", "hello",
"/upload","upload"
)
app = web.application(urls, globals())
import os
import json
import pprint
import csv
file = open( "filename_destination2.csv", "w")
files_in_dir = os.listdir('/home/shailja/readfiles')
import matplotlib.pyplot as plt
import matplotlib.dates as md
import numpy as np
import datetime as dt
import time
data = np.genfromtxt('/home/milan/Projects/Summer_Project/AC/Data/data_1.csv',delimiter=',',names=['time1','date','temperature','humidity'])
#data2 = np.genfromtxt('/home/milan/Projects/Summer_Project/AC/Data/data_2.csv',delimiter=',',names=['time2','power'])
time = data['time1']
humidity = data['humidity']
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.