This worked fine before but now I get the error C:\...\Django\sw2\wkw2>csv2json.py csvtest1.csv wkw2.Lawyer Converting C:\...\Django\sw2\wkw2csvtest1.csv from CSV to JSON as C:... \Django\sw2\wkw2csvtest1.csv.json Traceback (most recent call last): File "C:\...\Django\sw2\wkw2\csv2json.py", line 37, in <module> f = open(in_file, 'r' ) IOError: [Errno 2] No such file or directory: 'C:\\...\\Django\\sw2\ \wkw2cvtest1.csv'
>From the snippet http://www.djangosnippets.org/snippets/1680/: 31 in_file = dirname(__file__) + input_file_name 32 out_file = dirname(__file__) + input_file_name + ".json" 34 print "Converting %s from CSV to JSON as %s" % (in_file, out_file) 36 f = open(in_file, 'r' ) 37 fo = open(out_file, 'w') It seems to combine the directory name and file name? Thanks. On Nov 14, 7:42 am, Zeynel <azeyn...@gmail.com> wrote: > Great, thank you. When I ran it in the command prompt it worked fine. > I noticed that the first column needs to be "pk" with rows starting > with integers. > > On Nov 13, 11:24 pm, Karen Tracey <kmtra...@gmail.com> wrote: > > > > > On Fri, Nov 13, 2009 at 10:57 PM, Zeynel <azeyn...@gmail.com> wrote: > > > Thanks, I tried but this did not work either: > > > > >>> csv2json.py sw.csvwkw1.Lawyer > > > > File "<stdin>", line 1 > > > csv2json.py sw.csvwkw1.Lawyer > > > ^ > > > SyntaxError: invalid syntax > > > You need to run the .py script from an OS shell (command prompt), not from > > within a Python shell. > > > Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.