[EMAIL PROTECTED] wrote:
> import csv
> import MySQLdb
> import sys
>
> try:
> datei = sys.argv[1]
> except:
> print("Usage: insert_into_db <.csv-file>")
>
> # convert csv to list
> reader = csv.reader(open(datei, "rb"), delimiter = ";", quotechar = "",
> quoting = csv.QUOTE_NONE)
> </snip>
>
> After copying it to the server, it says:
>
> server1:/usr/local/sbin# ./insert_dgf_customers.py /usr/local/sbin/my.csv
> Traceback (most recent call last):
> File "./insert_dgf_customers.py", line 27, in ?
> reader = csv.reader(open(datei, "rb"), delimiter = ";", quotechar =
> "", quoting = csv.QUOTE_NONE)
> TypeError: bad argument type for built-in operation
>
>
> The file my.csv is a test file and correctly formatted (it's the same
> file that worked on the other machine).
It doesn't seem to get as far as actually reading the file.
> I thought the built-in operation meant here is open(), but without
> putting csv.reader() around it everything works fine... And I guess
> csv.reader is _not_ built-in, for it from the module - is that correct?
csv.reader is not built-in, that is correct. But it is implemented in C
so you won't get a good traceback into where the failure is actually
occurring.
What version of Python is on the two machines?
A couple of things to try, maybe some hints will come out:
- print the value of datei just to make sure nothing funny there
- split the open to a separate line to make sure it is the call to
reader that is the problem:
f = open(datei, "rb")
reader = csv.reader(f, delimiter = ";", quotechar = "", quoting =
csv.QUOTE_NONE)
Kent
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor