#!/usr/bin/env python

from os import listdir
from os import remove

files = listdir("./pressure")
files += listdir("./delta")
files += listdir("./ghg")
files += listdir("./onemed_ghg")
files += listdir("./onemed_delta")

for f in files:
    try:
        lines = open("./pressure/{}".format(f), 'r')
        if not lines.readline().startswith("{"):
            remove("./pressure/{}".format(f))
    except:
        pass
    try:
        lines = open("./delta/{}".format(f), 'r')
        if not lines.readline().startswith("{"):
            remove("./delta/{}".format(f))
    except:
        pass
    try:
        lines = open("./ghg/{}".format(f), 'r')
        if not lines.readline().startswith("{"):
            remove("./ghg/{}".format(f))
    except:
        pass
    try:
        lines = open("./onemed_ghg/{}".format(f), 'r')
        if not lines.readline().startswith("{"):
            print(f)
            remove("./onemed_ghg/{}".format(f))
    except:
        pass
    try:
        lines = open("./onemed_delta/{}".format(f), 'r')
        if not lines.readline().startswith("{"):
            remove("./onemed_delta/{}".format(f))
    except:
        pass
