Date post: | 19-Dec-2015 |
Category: |
Documents |
View: | 213 times |
Download: | 0 times |
Title
Center for Coastal Center for Coastal and Ocean Mapping and Ocean Mapping NOAA/UNH Joint NOAA/UNH Joint Hydrographic CenterHydrographic Center
WindowsWindowsPython Python
TutorialTutorial
Kurt Schwehr
Jan 2007
First some review of Day 1
• We covered a lot of ground yesterday
• Please ask if you have any questions
Now read the file• Finish the for loop by going by unindenting• Each line is getting to new line characters• Use a comma to prevent the double end line
Now we need to get these values to be numbers• The variable line still has the last line read• How can we get the float values of “3 2.2”
Now put it all together in a script• Use SciTE to create the file• SciTE does not know this is python until you save the file
Write some data to disk• Use file to open a file, but tell it ‘w’ to open for writing• write does not append a newline and only takes strings• Close the file to make sure the data is written into the file