1

I am very new to Python and am attempting to use it for some relative humidity data. I am looking at 60 months of data. The files include a Lat and Long file (CSV in a Matrix) and Relative Humidity data (60 CSV Matrix files). What I'm trying to do is correspond the Lat and Long to the value in the Relative Humidity files by turning them into 60 CSV XYZ (latitude, longitude. RH) files - essentially merging the data and converting from matrix to list form. My problem is I don't know how to loop through the RH files.

# Create XYZ CSV file from Latitude, Longitude, and relative_humidity files
import csv

path = "/Users/msayre1/Desktop/CSV_Input/" 
longitude = []
latitude = []
humidity = []

with open(path + 'LATITUDE.csv', 'rb') as f:
    reader = csv.reader(f)
    latitude = list(reader)

with open(path + 'LONGITUDE.csv', 'rb') as f:
    reader = csv.reader(f)
    longitude = list(reader)

with open(path + 'relative_humidityApr09.csv', 'rb') as f:
    reader = csv.reader(f)
    humidity = list(reader)

with open(path + 'RH_200904.csv', 'wb') as newFile:
    newWriter = csv.writer(newFile, delimiter = ',')
    for row, value in enumerate(latitude):
        for col, lati in enumerate(value):
            print lati + "," + longitude[row][col] + "," + humidity[row][col]
            newWriter.writerow([lati, longitude[row][col], humidity[row][col]])
  • 1
    This looks like a pure Python application, a formatting task without a GIS component. Can you edit the question to explain why GIS SE is a better fit than StackOverflow? There's also precious little information about the file formats, so there isn't much room to give even comment advice. – Vince Mar 17 '16 at 2:31

Browse other questions tagged or ask your own question.