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]])

closed as off-topic by PolyGeo Mar 17 '16 at 2:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions relating to general Information Technology, with no clear GIS component, are off-topic here, but can be researched/asked at Stack Overflow (software development), Super User (computing hardware and software) and Database Administrators (relational databases)" – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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.