lundi 23 mars 2015

Converting csv that it can be displayed


I have this Excel sheet here (far to right side there is a box where the file can be downloaded, the very first one). http://ift.tt/1OrBcKw


Im interested in the GRDC stations (GRDC Metadata). Opening that in ArcGis does not work (the attributetable gets messed up), so I decided to save that file as a .csv and rewrite it to get rid of all leading and trailing spaces and other inconsistencies which might occur. Well, that did not work and the error message provided by ArcMap 10 does not help neither


A selected item could not be added to the map. General function failure. General function failure [betterCSV.csv]


There is file called Shema created in the folder where my .csv is located (after trying to open it in Arc Map).


Here is my script which I tried (I tried several things already):



import csv
f = open("Copy of 20141218_GRDC_Stations_edited2.csv", "r")
nf = open("betterCSV.csv", "w")

reader = csv.reader(f)

for row in reader:
#print type(row)
for j in row:
a = j.strip()
#print a
nf.write(a + ",")
nf.write("\n")

f.close()
nf.close()


Yes, afterwards there are some _ in the header (first line) which I deleted manually out of the .csv file. I tried \t instrad of , but that did not help. I opened the file in Excel and instead of tabs there were ? in squares. But still, problems.


Any ideas?





Aucun commentaire:

Enregistrer un commentaire