From rshepard at appl-ecosys.com Tue Feb 1 21:46:31 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 1 Feb 2011 12:46:31 -0800 (PST) Subject: [portland] Reformatting Data Files In-Reply-To: References: <4D4329FA.1080202@stoneleaf.us> Message-ID: On Fri, 28 Jan 2011, Kyle Jones wrote: > It isn't anything pretty, but I think this might be similar: > http://paste.pocoo.org/show/328545/ Kyle/John/Ethan/Dylan/Jerry, Pretty enough. What I still need to figure out is why csv.writer() is not writing proper delimited output. Here's an example of output lines: JCM-20B,2008-11-13,Depth to Water,97.08 JCM-20B,2008-11-13,pH,7.40 JCM-20B,2008-11-13,Total Dissolved Solids,211 JCM-20B,2008-11-13,"Alkalinity, Bicarbonate",167 Notice that the third item is not quoted unless the text contains a comma. What I want for output is to have all text fields (that is, all but the last one) quoted, preferably with single quotes to keep postgres happy. This output is produced by: outfile = open('out.csv', 'w') outdata = csv.writer(outfile) for row in indata: for i, location in enumerate(loc): if i == 0: continue outdata.writerow([location, sampdate[i], row[0], row[i]]) When I change the csv.writer() method to 'csv.writer(outfile, quotechar = "'", delimiter = ':')' no text is quoted, including Alkalinity, Bicarbonate above. What have I missed in reading the csv module page? Thanks all, Rich From kyle at bucebuce.com Tue Feb 1 22:07:01 2011 From: kyle at bucebuce.com (Kyle Jones) Date: Tue, 1 Feb 2011 13:07:01 -0800 Subject: [portland] Reformatting Data Files In-Reply-To: References: <4D4329FA.1080202@stoneleaf.us> Message-ID: I didn't test it, but you probably want quoting=csv.QUOTE_NONNUMERIC You will then need to convert that value (which was read in as a string) to an integer/whatever-numeric-form before writing it. On Tue, Feb 1, 2011 at 12:46 PM, Rich Shepard wrote: > On Fri, 28 Jan 2011, Kyle Jones wrote: > > It isn't anything pretty, but I think this might be similar: >> http://paste.pocoo.org/show/328545/ >> > > Kyle/John/Ethan/Dylan/Jerry, > > Pretty enough. > > What I still need to figure out is why csv.writer() is not writing proper > delimited output. Here's an example of output lines: > > JCM-20B,2008-11-13,Depth to Water,97.08 > JCM-20B,2008-11-13,pH,7.40 > JCM-20B,2008-11-13,Total Dissolved Solids,211 > JCM-20B,2008-11-13,"Alkalinity, Bicarbonate",167 > > Notice that the third item is not quoted unless the text contains a comma. > What I want for output is to have all text fields (that is, all but the > last > one) quoted, preferably with single quotes to keep postgres happy. > > This output is produced by: > > outfile = open('out.csv', 'w') > outdata = csv.writer(outfile) > > for row in indata: > for i, location in enumerate(loc): > if i == 0: > continue > outdata.writerow([location, sampdate[i], row[0], row[i]]) > > When I change the csv.writer() method to 'csv.writer(outfile, quotechar = > "'", delimiter = ':')' no text is quoted, including Alkalinity, Bicarbonate > above. > > What have I missed in reading the csv module page? > > Thanks all, > > > Rich > > > > _______________________________________________ > Portland mailing list > Portland at python.org > http://mail.python.org/mailman/listinfo/portland > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ethan at stoneleaf.us Tue Feb 1 22:18:34 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 01 Feb 2011 13:18:34 -0800 Subject: [portland] Reformatting Data Files In-Reply-To: References: <4D4329FA.1080202@stoneleaf.us> Message-ID: <4D4878AA.3080403@stoneleaf.us> Rich Shepard wrote: > What I still need to figure out is why csv.writer() is not writing proper > delimited output. Here's an example of output lines: > > JCM-20B,2008-11-13,Depth to Water,97.08 > JCM-20B,2008-11-13,pH,7.40 > JCM-20B,2008-11-13,Total Dissolved Solids,211 > JCM-20B,2008-11-13,"Alkalinity, Bicarbonate",167 > > Notice that the third item is not quoted unless the text contains a > comma. > What I want for output is to have all text fields (that is, all but the > last > one) quoted, preferably with single quotes to keep postgres happy. Rich, Try adding quoting=csv.QUOTE_NONNUMERIC to your writer invocation. ~Ethan~ From rshepard at appl-ecosys.com Tue Feb 1 22:50:33 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 1 Feb 2011 13:50:33 -0800 (PST) Subject: [portland] Reformatting Data Files In-Reply-To: References: <4D4329FA.1080202@stoneleaf.us> Message-ID: On Tue, 1 Feb 2011, Kyle Jones wrote: > I didn't test it, but you probably want quoting=csv.QUOTE_NONNUMERIC Kyle, That makes a difference. > You will then need to convert that value (which was read in as a string) > to an integer/whatever-numeric-form before writing it. Will do. Thanks, Rich From rshepard at appl-ecosys.com Wed Feb 2 18:55:33 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Wed, 2 Feb 2011 09:55:33 -0800 (PST) Subject: [portland] Reformatting Data Files In-Reply-To: References: Message-ID: My question is why the output file, out.csv, displays in emacs as having DOS end-of-lines instead of the normal UNIX \n? Here is the script that I'm using; it's essentially what Kyle threw together: --------------------- #!/usr/bin/env python import sys,csv filename = sys.argv[1] try: infile = open(filename, 'r') except: print "Can't open ", filename,"!" sys.exit(1) indata = csv.reader(infile, delimiter=':', quotechar="'") loc = indata.next() sampdate = indata.next() # check for mis-match in number of columns assert len(loc) == len(sampdate) outfile = open('out.csv', 'w') outdata = csv.writer(outfile, quoting = csv.QUOTE_NONNUMERIC, quotechar = "'", delimiter = ':') # The next rows are our parameters. for row in indata: # iterate through each column for the particular locations for i, location in enumerate(loc): # ignore the first column, which contains the parameter name if i == 0: continue # Write the location, the date for this column, the parameter name # (which is the first column in this row), and the value. if row[i] != '': float(row[i]) outdata.writerow([location, sampdate[i], row[0], float(row[i])]) else: row[i] = '' outdata.writerow([location, sampdate[i], row[0]]) infile.close() outfile.close() ----------------- Rich From michelle at pdxpython.org Tue Feb 8 21:54:03 2011 From: michelle at pdxpython.org (Michelle Rowley) Date: Tue, 8 Feb 2011 12:54:03 -0800 Subject: [portland] PDX Python: Tonight! 6:30pm @ Urban Airship Message-ID: Happy Second Tuesday, Pythonistas! Tonight's meeting at Urban Airship should be a fun one. Dan Colish will start us off with Michel's Monthly Module, binascii. Following that, Eric Holscher will present: Exploring Read the Docs - an open source Django site (http://readthedocs.org). The fun begins at 6:30pm. Feel free to bring a couple bottles of your favorite beverage to drink or trade during the presentations. We'll probably move on to a pub nearby to continue the discussion afterwards. Urban Airship is at 334 NW 11th Ave, in the Pearl District: http://goo.gl/maps/U6mC The main door will probably be locked, but the back door, which leads directly to the event space, will be propped open. The back door is right around the corner on NW Flanders, next to the loading dock: http://goo.gl/maps/Ikbh Hope to see you there! Michelle -------------- next part -------------- An HTML attachment was scrubbed... URL: From brian.curtin at gmail.com Wed Feb 9 15:43:10 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Wed, 9 Feb 2011 08:43:10 -0600 Subject: [portland] PyCon 2011 news - going strong, sign up today! Message-ID: Hello group! PyCon 2011 looks like it may very well break every single record in the past - making it one of the biggest and best PyCons of all time. We've gone all out this year - including Extreme Talks, a Startup Row, amazing talks, tutorials, Poster sessions. Extreme talks: http://us.pycon.org/2011/speaker/extreme/ Startup Row: http://us.pycon.org/2011/blog/2011/01/19/announcing-startup-row-pycon-2011/ Also just announced - "Startup Stories": http://us.pycon.org/2011/blog/2011/02/07/pycon-2011-announcing-startup-stories/ If you haven't bought your PyCon tickets, it's time to do so. This year we're limited to 1500 attendees, and with a faster than average sales rate compared to previous years, you may not have the luxury of leaving registration until just before the conference -- places may sell out in advance! Check out http://us.pycon.org/2011/tickets/ for rates and details. Not sold on the conference? Not sure what it's all about? We are confident this year's conference will surpass anything that has gone before, and we think there's something for everyone. Looking for education? This year's tutorial selection features a range of topics and an all-star cast of presenters. From the cloud to the GUI, from beginner to advanced, we have it. Check out courses taught by book authors Wesley Chun and David Beazley, web framework master Jacob Kaplan-Moss, core developer and guru Raymond Hettinger, hacker extraordinaire Zed Shaw and many more: http://us.pycon.org/2011/schedule/tutorials/ -- and at flat fees that wouldn't buy you an hour of training by less-qualified instructors elsewhere! The conference talks are some of the best we've seen in years, coming from a record number of submissions. We've got talks on using Python for airplane tuning and massive telescopes. All of the major web frameworks will be discussed. Numerous databases are covered. PyPy, IronPython and Jython are in. We'll be talking about IDEs, testing, security, scalability, and documentation. Have a look: http://us.pycon.org/2011/schedule/lists/talks/ We've also got an amazing array of poster presentations - everything from Arduino hacking, Geospatial Python, Open Government and Microsoft Kinect hacking. Check out: http://us.pycon.org/2011/schedule/lists/posters/ Meanwhile we've got the awesome sprints (http://us.pycon.org/2011/sprints/ ), and open spaces (http://us.pycon.org/2011/openspaces/) everyone knows and loves. This is shaping up to be the best PyCon yet, and we think it's a great value, both cost-wise, and community-wise. We can guarantee that you'll come away with a head full of knowledge and amazing new friends and contacts. Get your tickets before they are gone: http://us.pycon.org/2011/tickets/ If you have any questions, comments or concerns - feel free to email Van Lindberg (van at python.org) or Jesse Noller (jnoller at python.org) or pycon-organizers (pycon-organizers at python.org). See you in Atlanta, Van Lindberg Jesse Noller The entire PyCon 2011 team http://us.pycon.org/2011 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcolish at gmail.com Thu Feb 10 03:12:53 2011 From: dcolish at gmail.com (dcolish at gmail.com) Date: Thu, 10 Feb 2011 02:12:53 +0000 Subject: [portland] Portland PSF Sprint Signup Form Message-ID: <0016e644ddc48919fc049be41ebc@google.com> If you have trouble viewing or submitting this form, you can fill it out online: https://spreadsheets0.google.com/viewform?formkey=dHhGYjVfMlR4Wldub3luMVlkc3pXR3c6MQ Portland PSF Sprint Signup Form Join us for a Python code sprint on Saturday, February 26th @ Urban Airship. For more details: http://goo.gl/Ln68F Name * Projects you'd like to work on * Select from the following projects. You can select more than one. Developing core features in py3k Fabric Django Flatland PyPy Alfajor Suggest New Topic If none of the topics available are of interest, suggest a new one. Comments Anything you'd like to let the organizers know. Powered by Google Docs Report Abuse - Terms of Service - Additional Terms -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at susens-schurter.com Thu Feb 10 21:19:56 2011 From: michael at susens-schurter.com (Michael Schurter) Date: Thu, 10 Feb 2011 12:19:56 -0800 Subject: [portland] Bump sponsoring web design for new Diesel site Message-ID: Hi all, Bump[1], the startup behind the Bump mobile app, is looking to relaunch the web site for the Diesel framework and is willing to pay a designer for wireframes (html/css/images). Diesel[2] is an asynchronous IO framework for Python that went through a significant change from being generator (yield) based to using greenlet, and they're working on relaunching the site dieselweb.org to reflect the new diesel. This is more of a design gig than Python one as Bump will take care of actually implementing the site[3], so feel free to pass this along to any designers you know. Contact Jamie Turner if you're interested! Thanks, schmichael [1] http://bu.mp/ [2] https://github.com/jamwt/diesel [3] Jamie thinks it will probably just be a simple diesel app maybe using mako templates, so if you're willing to provide templates it might be worth mentioning.