Skip to content

Commit

Permalink
Updated README and removed args from commandline
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenbert Del Rosario committed Oct 4, 2010
1 parent db97224 commit 9ad0728
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
13 changes: 12 additions & 1 deletion README
@@ -1,2 +1,13 @@
USAGE:
$> python convert_tide.py source_file.txt new_file.txt
$ python convert_tide.py
Tide Format Converter
CTRL + C to exit
Enter the location of file you want to convert: non-existen-file.txt
'non-existen-file.txt' not found.
Please enter again the filename you want to convert: waterlevel.txt
Enter the filename of the output file: converted_waterlevel.txt
Creating file converted_waterlevel.txt .....
-------------------------------------------------------------
Time zone is GMT + 1 hour in the Winter Time
and GMT + 2 hours in the Summer Time (daylight saving time).
Press enter to exit
21 changes: 10 additions & 11 deletions convert_tide.py
@@ -1,26 +1,30 @@
from sys import argv
import os

script, input_file, output_file = argv
"""
input_file: your tide input file
output_file: the name of the output file
"""
print "Tide Format Converter"
print "CTRL + C to exit"

#input_file = raw_input("Enter the location of file you want to convert: ")
#output_file = raw_input("Enter the filename of the output file: ")
input_file = raw_input("Enter the location of file you want to convert: ")

while not os.path.exists(input_file):
print "'%s' not found." % input_file
input_file = raw_input("Please enter again the filename you want to convert: ")

if os.path.exists(input_file):
output_file = raw_input("Enter the filename of the output file: ")

start_line = 8 #you can edit this

i = 0;
error = False
cwd = os.getcwd()
try:
new_file = open(output_file, 'w')
new_file.truncate()
print "Creating file:", output_file,
print "Creating file %s ....." % output_file

for line in open(input_file, 'r'):
if i >= start_line: #start reading at specified linen number
Expand All @@ -47,12 +51,7 @@
print "Time zone is GMT + 1 hour in the Winter Time"
print "and GMT + 2 hours in the Summer Time (daylight saving time)."

except IOError as (errno, strerror):
print "I/O error({0}): {1}".format(errno, strerror)
except ValueError:
print "Could not convert data to an integer."
except:
print "Unexpected error:", sys.exc_info()[0]
raise
print "Unexpected error"

raw_input("Press enter to exit")

0 comments on commit 9ad0728

Please sign in to comment.