# Open the file FILE = open(output_file, "a") # Write the header (so I can remember what each column is!) FILE.write("name,n,mean_len,total_len,max_len,min_len,stdev_len,mean_closeness,std_closeness,defect_dens,r_score,z_score,p_value\n") # Get the line that I need to write to the CSV file (it is returned from a function I wrote to do my processing) csv_line = process_file(full_path) # Print it to the screen (just for testing really) print csv_line # Write it to the file FILE.write(csv_line + "\n") # Close the file FILE.close()
# Put all of the statistics into a list - in this case all of the items in the list are variables that I have calculated output_stats = [tidied_file_name, n_dunes, mean_len, total_len, max_len, min_len, stdev_len, mean_closeness, std_closeness, defect_dens, r_score, z_score, p_value] # For each of the items in this list, convert it to a string and append to an array for item in output_stats: csv_array.append(str(item)) # Join this array, adding commas between all the items csv_string = ",".join(csv_array) # Return this comma joined array ready to write to the file return csv_string
def writefile(file, list): f = open(file,"w") f.write("EASTING, NORTHING, READING\n") for record in list: f.write("%i, %i, %s\n" % (record[0],record[1],record[2])) f.close() return
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.