Ejemplo n.º 1
0
def dumpSQLCSVFiles(writers, records):
    for record in records:
        # fix datetime "%Y-%m-%d %H:%M:00"
        datetime = record.date[0:4]+'-'+record.date[4:6]+'-'+record.date[6:8]+' '+ \
            record.hrmn[0:2]+':'+record.hrmn[2:4]+':00' 
        # FIXME -- unmunge the temp_minmax readings
        # FIXME --  vis_variable_flag           precip_hist_contin
        #           temp_minmax[12]_minmax      cloud_ceil_CAVOK    precip_lq[1234]_trace_fl
        # dump each record subset in the appropriate file.
        key = (record.id_NCDC, record.id_USAF, datetime)
        for component in weatherComponents:
            vals = tuple( fixForSQL(getattr(record, field)) for field in weatherComponentFields[component] )
            writers[component].writerow(key + vals)
Ejemplo n.º 2
0
def dumpSQLCSV(filename, records):
    print('Writing ' + filename)
    writer = csv.writer(open(filename, "wb"))
    for record in records:
        vals = [fixForSQL(getattr(record, slot)) for slot in record.__slots__]
        writer.writerow(vals)
Ejemplo n.º 3
0
def dumpSQLCSV(filename, records):
	print ('Writing '+filename)
	writer = csv.writer(open(filename, "wb"))
	for record in records:
		vals = [fixForSQL(getattr(record, slot)) for slot in record.__slots__]
		writer.writerow(vals)