On Thu, Jan 7, 2010 at 1:26 PM, Lowell Tackett <[email protected]> wrote:
> I found the Python documentation (on line} and came
> across--'csv.Dialect.skipinitialspace' which I believe is the answer to my
> dilemma. However, my effort to implement that detail, based on interpreting
> the skimpy examples in the documentation:
>
> >>> coord = csv.reader(open('true_coord'),csv.Dialect.skipinitialspace = True)
>
> got me roundly shot down with:
>
> File "<stdin>", line 1
> SyntaxError: keyword can't be an expression
Try
coord = csv.reader(open('true_coord', 'b'), skipinitialspace = True)
Or you could create a Dialect and pass it as a second argument to open(). Try
dialect = csv.excel() # start with the default dialect
dialect.skipinitialspace = True
coord = csv.reader(open('true_coord', 'b'), dialect)
Note you should open the file in binary mode.
Kent
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor