From: Tara G. <tg...@cs...> - 2010-03-17 21:37:04
|
Hi Axel, I did try adding in a comma option to the regexp earlier (although without the whitespace, as I never have any) and couldn't get it working, probably just some syntax error I couldn't find. :p Anyway, that works a treat now, thanks very much! Tara Axel Freyn wrote: > Hi Tara, > On Wed, Mar 17, 2010 at 05:05:10PM +0000, Tara Gilliam wrote: >> Hi, >> >> I've been trying to plot a nested bar chart from some data in a csv file. >> I couldn't find a simple way to swap the column separator from whitespace >> to comma (I tried tweaking the regexp for the columnpattern, but couldn't >> get it to work), so I've ended up using graph.data.list instead. > Well, there I know a solution: > If you use "(.*?)(,\s*|\s+|$)" as columnpattern, he will understand: > 1,2 > 1, 2 > 1, 2 > 1 2 > 1 2 > so: > - a commma, followed by an arbitrary (0 or more) number of spaces > - no comma, but one or more spaces > > you can change this separator within one file. The generalized > "minimal.py" reads: > > import re > from pyx import * > g = graph.graphxy(width=8) > g.plot(graph.data.file("minimal.dat", > g.plot(graph.data.file("minimal.dat", columnpattern=re.compile(r"(.*?)(,\s*|\s+|$)"), x=1, y=2)) > g.writeEPSfile("minimal") > g.writePDFfile("minimal") > > HTH, > > Axel > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > PyX-user mailing list > PyX...@li... > https://lists.sourceforge.net/lists/listinfo/pyx-user |