Re: [Tutor] import data (txt/csv) into list/array and manipulation
On Mon, Nov 10, 2008 at 12:12 PM, trias <[EMAIL PROTECTED]> wrote: > I have started learning python (any online help content suggestions are > welcome) and want to write a couple of scripts to do simple numeric > calculations on array data. Welcome! Have you seen http://wiki.python.org/moin/BeginnersGuide/NonProgrammers > filetype(1) I have reference files (ie file.csv) that contain three columns > with variable rows, first column is type str contains a unique identifier > name, and the other two columns are int type contain two reference values > (start,stop(genomic location reference values). > **maybe I should import this as dictionary list** I don't know what a dictionary list is, do you mean a list of dictionaries? I think a list of lists is probably fine. Python comes with a csv module that helps to read csv files. Then you will have to convert the second two columns from string to int. > filetype(2) The other file contains signal data in three columns, column one > is a unique identifier type int, and the other two columns contain two type > int values (genomic location reference values) > ** import this as array/list > > I want to map the location of filetype(2) with respect to filetype(1) and be > able to do averaging of signal if I align all filetype one objects. I don't know what you mean by this. I guess you want to search within filetype(1) for intervals that contain the locations from filetype(2) ? This is pretty straightforward but if you have long lists it may be slow. This recent thread has some suggestions for speeding up searching large data sets: http://thread.gmane.org/gmane.comp.python.tutor/51162/focus=51181 It looks like you and Srinivas are trying to solve similar problems. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] import data (txt/csv) into list/array and manipulation
filetype(2) The other file contains signal data in three columns, column one is a unique identifier type int, and the other two columns contain two type int values (genomic location reference values) ** import this as array/list I want to map the location of filetype(2) with respect to filetype(1) and be able to do averaging of signal if I align all filetype one objects. Thanks import numpy as np data = np.loadtxt('file.csv', dtype='|S10') col1 = date[0] col2 = date[1].astype(int) ... ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] import data (txt/csv) into list/array and manipulation
Hi, I have started learning python (any online help content suggestions are welcome) and want to write a couple of scripts to do simple numeric calculations on array data. filetype(1) I have reference files (ie file.csv) that contain three columns with variable rows, first column is type str contains a unique identifier name, and the other two columns are int type contain two reference values (start,stop(genomic location reference values). **maybe I should import this as dictionary list** filetype(2) The other file contains signal data in three columns, column one is a unique identifier type int, and the other two columns contain two type int values (genomic location reference values) ** import this as array/list I want to map the location of filetype(2) with respect to filetype(1) and be able to do averaging of signal if I align all filetype one objects. Thanks -- View this message in context: http://www.nabble.com/import-data-%28txt-csv%29-into-list-array-and-manipulation-tp20424075p20424075.html Sent from the Python - tutor mailing list archive at Nabble.com. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question
On Mon, Nov 10, 2008 at 11:07 AM, Michael Connors <[EMAIL PROTECTED]> wrote: > My guess is that, if you want to provide instructions to someone with no > linux/unix experience. e.g. to edit a config file, you can safely tell them > to: nano myfile.conf and expect them to be able to save the file and return > to the command line. If you want to give the same instructions using vim or > emacs, you would also need to specify how to save and exit. I imagine this > to be the reason it is popular in tutorials, and if all the tutorials you > use, use nano, you will probably use it too. Yes. I don't use vim or emacs. When I need a terminal-based editor I use nano because I can figure it out. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question
"Python Nutter" <[EMAIL PROTECTED]> wrote On the Mac I just linked ipython in the config file to nano On the iPhone 3G I just linked ipython in the config file to nano On the Linux/Ubuntu box I also linked to nano... hmmm looks like I use nano a lot more than I though ;-) Nothing to do with Python directly, but I'm curious... nano is a very popular editor in Unix/Linux circles but I confess I never could figure out why? Is there something I'm missing? What does nano do that vi (or emacs) doesn't? Given that vi is the "standard" editor on *nix ity would seem the obvious choice. But everyone seems to be using nano? Why? PS. I should explain that I used to use Unix a lot but it was before nano appeared to proliferate so I never used it. Now I only use *nix occasionally but nano is everywhere it seems. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question
2008/11/10 W W <[EMAIL PROTECTED]> > On Mon, Nov 10, 2008 at 9:40 AM, Alan Gauld <[EMAIL PROTECTED]>wrote: > >> > > What does nano do that vi (or emacs) doesn't? Given that vi is the >> "standard" editor on *nix ity would seem the obvious choice. But everyone >> seems to be using nano? Why? > > > AFAIK, it's a little smaller/faster than emacs... but since I'm a vi(m) > fan, I'm probably the wrong person for the question ;) > > > My guess is that, if you want to provide instructions to someone with no linux/unix experience. e.g. to edit a config file, you can safely tell them to: nano myfile.conf and expect them to be able to save the file and return to the command line. If you want to give the same instructions using vim or emacs, you would also need to specify how to save and exit. I imagine this to be the reason it is popular in tutorials, and if all the tutorials you use, use nano, you will probably use it too. -- Michael Connors ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question
On Mon, Nov 10, 2008 at 9:40 AM, Alan Gauld <[EMAIL PROTECTED]>wrote: > What does nano do that vi (or emacs) doesn't? Given that vi is the > "standard" editor on *nix ity would seem the obvious choice. But everyone > seems to be using nano? Why? AFAIK, it's a little smaller/faster than emacs... but since I'm a vi(m) fan, I'm probably the wrong person for the question ;) -Wayne > > PS. I should explain that I used to use Unix a lot but it was before nano > appeared to proliferate so I never used it. Now I only use *nix occasionally > but nano is everywhere it seems. > > Alan G. > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] cgi scripts
On Mon, Nov 10, 2008 at 7:00 AM, Jim Morcombe <[EMAIL PROTECTED]> wrote: > I have been using > import cgitb; cgitb.enable() > > It seems to re-direct some of the errors to the browser, but obviously not > all. Right, if the script fails before that line runs, of course it will have no effect. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] cgi scripts
Actually, that's good to know. I was thinking it was going to be pretty hard to debug if I couldn't tell the difference between HTML errors and Python errors. I have been using import cgitb; cgitb.enable() It seems to re-direct some of the errors to the browser, but obviously not all. Jim Don Jennings wrote: Hi, Jim. Actually, improper HTML would cause a problem with the browser and what it may or may not display. An "Internal Server Error" does indicate that you had a problem with your code. I suggest referring back to Alan's post again. Take care, Don ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question
I use Notepad++ on my Windows box for Python, but my feeling about it is a bit "Blah..." but thats my feeling with Windows in general ;-) I think I'm one of the rare ones who do not like its choice of Syntax Highlighting colours. But too lazy to change them since I don't do much development on my Windows box to warrant it now that I got a Mac on the desk as well. I use ipython a lot and linked to Notepad++ in it so on Windows just typing >>>edit somefile.py will auto launch Notepad++ and let me code then when I save/exit it will load the file automatically back into ipython and start interpreting it. On the Mac I just linked ipython in the config file to nano On the iPhone 3G I just linked ipython in the config file to nano On the Linux/Ubuntu box I also linked to nano... hmmm looks like I use nano a lot more than I though ;-) Cheers, PN ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [Fwd: Re: get a module's own (top_level) dict?]
(forwarded to the list) Hello pyhonistas, Example: === module content === a = 1 b = 2 == I'm looking for a way to get something like {'a':a, b':2}. Actually, names defind in the module will be instances of a custom type. I want to give them an attribute that holds their own name. E.g.: for key,obj in dict: obj.name = key Thank you Lie & Kent, that's it. Excuse me, Lie, I answered too fast. Now, to answer Kent questions, there are several reasons why I wish to do that. These objects will be of a 'pattern' type that (unlike function, for instance), don't know how they're called. They need to hold their name to pass it to further objects (say, tokens) that will be generated according to these patterns, but who are not instances of the patterns. Actually, the pattern's name is a kind of token 'type'. You see what I mean? Concretely, I need to instanciate object with a type specified by the pattern's name and init data given by the result of the parsing. Also, I want to write the pattern --> name --> type --> object toolset in a general to be able to reuse it. Also, simply because I want it so! There will be many such names, too. Also: the patterns will actually be generated at runtime according to a config file -- and can also change at runtime (--> reload() grammar module), following user customization. So that I don't even know the names at design time. Denis ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor