python-django for dynamic web survey?

2013-06-18 Thread chip9munk

Hi guys!

Please help me with your advices and ideas.

I need to create a web survey that will dynamically (randomly) select 
questions and descriptions from a dataset, present them to users, 
collect their answers and store them back in the dataset. (Every user 
gets different set of questions randomly selested from the pool.)


Since I am very inexperienced with this stuff I want to ask you if you 
thing that python (which I use) and django (which I have never used 
before) would be a good way to do this easily? I have seen there  are 
some django survey and crowdsourcing librarires...


What do you think? Is there an easier way?
I would like some fast, clean, modifyAndDoNotCodeFromScratch solution.

Thanks!

--
http://mail.python.org/mailman/listinfo/python-list


Re: python-django for dynamic web survey?

2013-06-18 Thread chip9munk

On 18-Jun-13 12:59 PM, andrea crotti wrote:

Django makes your life a lot easier in many ways, but you still need
some time to learn it.
The task you're trying it's not trivial though, depending on your
experience it might take a while with any library/framework..


I have an overall experience with languages, frameworks etc. I was 
hoping to get some simple example and than modify it to do what I need 
it to do.

--
http://mail.python.org/mailman/listinfo/python-list


Re: python-django for dynamic web survey?

2013-06-18 Thread chip9munk

On 19-Jun-13 7:04 AM, Jason Friedman wrote:


How random do the questions need to be?  Is a handful or two different
combinations sufficient?  Can you manually create these different
surveys using, for example, surveymonkey, and distribute them?


There are a lot possible combinations and questions so I would have to 
create a large number of them, so I guess automatic generation is a 
better way.


Thanks for the idea anyway!

--
http://mail.python.org/mailman/listinfo/python-list


scipy and numpy for Python3

2012-10-12 Thread chip9munk
Hello!

I am an absolute beginner in this.
Does anyone know hot to build scipy for python 3?

here: http://scipy.org/Installing_SciPy/Windows
it says that it was not yet tested... (?)

any help is appreciated!

any additional help for numpy is also welcome!

Thanx in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scipy and numpy for Python3

2012-10-12 Thread chip9munk
ok, i have solved it by the help from the previously mentioned page.

python 3.2 should be used, 3.3 has issues with building numpy and scipy.

-- 
http://mail.python.org/mailman/listinfo/python-list


python scripts for web

2012-10-18 Thread chip9munk
Hello all!

Please help me start learning about this thing. Sorry for my inexperience!

Here is what I need to do: on some webpage (done in php, or any other different 
technology), user inputs some data, that data and the request then goes to the 
server where python scripts calculate something and return the result to the 
users end. 

Now, how do I do that server part, listening to requests, and calling python 
scripts?

I googled about that but I do not understand if I should do that by CGI, Flask, 
mod_wsgi, or any other way... I know to little about that to understand what is 
the way to go. :/

Please could you give me some info so that i know where I should start looking 
for my solution.

Thanks in advance!



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python scripts for web

2012-10-18 Thread chip9munk
To explain, I am basically doing different algorithms and would like to make 
them work and be accessible as I mentioned in the example... and to add them to 
the functionality of a specific page... so I have experience in programming, 
just no experience in web development etc.. 

On Thursday, October 18, 2012 9:57:58 AM UTC+2, Zero Piraeus wrote:
> 
> If I understand you correctly, what you're describing here is a
> webserver - i.e. Apache, nginx etc. I'm not sure why you'd want to
> write one of those if you're as inexperienced as you say.
> These are all approaches to writing the software that the webserver
> hands the request off to, which is a different thing. If that's what
> you really meant to ask (how to write a script that processes a
> request and returns a response), then plain CGI might be the best
> place to start, if you're trying to get a handle on what's going on.

I understand how the lack of knowledge on my part can cause the unclarity of my 
question.
I will give you an example. So let us say I create two simple python scripts, 
one does the sum of two numbers
the other one does the multiplication. SO now I want to put these scripts on 
the server. Now let us say there is a web page that would like to use these 
scripts (do this calculation). How do I do a "program" that will listen for the 
requests
from the web page and call the scripts on the request?  
 
> Once you're happy that you understand how to build a plain CGI script,
> frameworks [like Flask] can be very useful ... and Flask is both
> lightweight and has good documentation, so it's not a bad choice for
> learning purposes.

all the tutorials about flask are dealing wit creating the whole webpage in 
python. I do not need to do that, I just need a service on the servers end.. is 
flask still the way to go? Also flask does not support Python 3.x jet, would 
using cherryPy be a good idea?

Thank you for the answers! 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python scripts for web

2012-10-18 Thread chip9munk
On Thursday, October 18, 2012 10:42:56 AM UTC+2, Zero Piraeus wrote:
> That is exactly what a webserver does. Is there some reason you don't
> want to use e.g. Apache to handle the requests?

no reason at all. so i guess the solution is much easier then I have 
anticipated.
So i guess in that case i do not need cgi or anything?

Thank you for clearing that out!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python scripts for web

2012-10-18 Thread chip9munk
thank you for the answer!

On Thursday, October 18, 2012 12:03:02 PM UTC+2, Chris Angelico wrote:
> CGI is a protocol between Apache and your script. What you want to do
> is set up Apache to call your CGI scripts.



yes, but as I have just answered to Zero, is using mod_wsgi a better strategy?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python scripts for web

2012-10-18 Thread chip9munk
On Thursday, October 18, 2012 12:02:40 PM UTC+2, Zero Piraeus wrote:

> Assuming your scripts accept the request as sent and return an
> appropriate response, they are CGI scripts (unless there's some
> wrinkle in the precise definition of CGI that escapes me right now).

yes, they are, but, I came under the impression that it is not the most 
elegant/fast way to do it... shouldn't the mod_wsgi be a better strategy?
or am i mixing these therms?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python scripts for web

2012-10-18 Thread chip9munk
thank you guys for pointing the double posting issue out, I am having some 
issues with the news server i am using, so I am doing this via google.groups at 
the time! :)

i think i managed to fix it
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python scripts for web

2012-10-18 Thread chip9munk
On Thursday, October 18, 2012 11:10:45 PM UTC+2, Zero Piraeus wrote:
> WSGI would enable you to write a persistent application that sits
> around waiting for requests and returns responses for them as and
> when, as opposed to a simple CGI script that gets started each time a
> request comes in, and terminates once it's returned the response.

ok I see, you have made it very clear for me now!
 
> So it's really about startup time - if your scripts are just doing
> something simple and quick, WSGI is likely overkill.

these scripts will do a lot of calculation on a big dataset, and it is possible 
that there will be many requests in a short period of time.
So I guess the WSGI is a better solution.

Thank you and the others very much, you have saved me a lot of time!

Cheers! 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python scripts for web

2012-10-23 Thread chip9munk
On Friday, October 19, 2012 12:32:48 PM UTC+2, Gilles wrote:
> In that case, are you sure a web script is a good idea? If you're
> thinking web to make it easy for people to upload data, click on a
> button, and get the results back, you might want to write the UI in
> Python but write the number crunching part in a compiled language.

well actually I would like to separate the web interface with this API...
that is why I would like to work on the server side and not think about the 
interface side.



-- 
http://mail.python.org/mailman/listinfo/python-list


debugging in eclipse

2012-11-15 Thread chip9munk
Hi all!

I have a stupid problem, for which I cannot find a solution...

I have a python module, lets call it debugTest.py.

and it contains:
def test():
a=1
b=2
c=a+b
c

so as simple as possible.

Now I would like to debug it in eclipse.. (I have pydev and all)
so the question is how do I debug the test function? (by debug I mean go into 
it in the debugging mode and execute step by step, inspect the variables and so 
on.. you know, like it is so easily done in Matlab for example).

I place a break point in the function, run the debugger and it stars and is 
terminated immediately. (of course it does not know where to go..)

So how can I do this? please help!

Thank you all in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: debugging in eclipse

2012-11-15 Thread chip9munk
On Thursday, November 15, 2012 1:49:22 PM UTC+1, Roy Smith wrote:
> Heh.  It took me a while to realize that the subject line was not 
> referring to 
> http://en.wikipedia.org/wiki/Solar_eclipse_of_November_13,_2012

:))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: debugging in eclipse

2012-11-15 Thread chip9munk
On Thursday, November 15, 2012 2:42:09 PM UTC+1, Dave Angel wrote:
> Add a call to test() to the end of the file, and it might do better. 
> 
> I'd also add a print statement, just to assure yourself that it's running.
> 
> 

thanks, that is it, (stupid me) now if I have many functions in the model I 
will simply ad a call to the specific function at the end and that is it... 

working on the project too long, all the simple and smart ideas are long gone ;)

thanks! 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: debugging in eclipse

2012-11-15 Thread chip9munk
On Thursday, November 15, 2012 2:44:22 PM UTC+1, Martin P. Hellwig wrote:
> I assume you have at the end of the debugTest.py file something like this: 
> if __name__ == '__main__':
>test()

no i did not have it...

is main really necessary? 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: debugging in eclipse

2012-11-15 Thread chip9munk
On Thursday, November 15, 2012 2:43:26 PM UTC+1, Ulrich Eckhardt wrote:
> Should that be "return c" instead of "c" on a line?

oh it is just a silly example function, the functionality is not important. It 
does not have to return anything...

> For a start, I would try to actually call the function. Just add 
> "print(test())" after the function definition.

yes I call the function now, that was the thing...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: debugging in eclipse

2012-11-15 Thread chip9munk
On Thursday, November 15, 2012 3:21:52 PM UTC+1, Alister wrote:
> doing it that way means that it will only call test when executed 
> directly & not when imported as a module

I see, thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


editing conf file

2012-11-16 Thread chip9munk

Hi all!

I would like to use conf file to get all the variables in my code. And 
it works great. I use the following (simple example):


execfile("example.conf", config)
print config["value1"]

and it works like a charm.

Now the problem is I do not know how to edit the conf file...
let us say that I calculate something and would like to save it in the 
conf file so that it is set for the next run of some program.


How do I edit a specific value in the conf file? (I would like to avoid 
editing txt if possible)...


I should also mention that I use Python 3.. so some of the solutions I 
came across are not compatible...


Thanks!!
--
http://mail.python.org/mailman/listinfo/python-list


Re: editing conf file

2012-11-16 Thread chip9munk

ok, I've got it:
http://docs.python.org/3.1/library/configparser.html

works like a charm!

Sorry for the unnecessary question. :/



--
http://mail.python.org/mailman/listinfo/python-list


Re: editing conf file

2012-11-16 Thread chip9munk

On 11/16/2012 1:35 PM, rusi wrote:

And there may be better options (allows nested sections)
http://www.voidspace.org.uk/python/configobj.html



but it does not seem to work with python 3

I have an issue...
configparser has four functions: get, getboolean, getfloat and getint.

how do I get list from cfg file?!

any ideas?
--
http://mail.python.org/mailman/listinfo/python-list


Re: editing conf file

2012-11-16 Thread chip9munk

On 11/16/2012 2:02 PM, Ulrich Eckhardt wrote:

Am 16.11.2012 13:06, schrieb chip9munk:

I would like to use conf file to get all the variables in my code. And
it works great. I use the following (simple example):

execfile("example.conf", config)
 print config["value1"]

and it works like a charm.


This works, but in general importing configuration data by loading and
executing code is a questionable approach. The problem is in particular
that the code parser is always more strict with the syntax than a
configuration file should be. Also, it presents the danger of code
injection, especially when exec'ing or importing untrusted code.


huh... ok, the thing is that there will actually be no code in the 
config file, just some variables and values.. it will be more like a 
"setting file"... so no execution of the config file is necessary, just 
getting and setting variables...




That said, if you really want full programmability inside that
configuration and are aware of the implications, you can do that. In
that case, I would rather call this a Python module though and instead
"from settings.py import *" to import any setting from this module (this
is similar to exec(), but less hack-ish). I use something similar to
import settings for automated tests, but still wouldn't recommend it for
general use.


thank you for the tip!


If you don't want that, use a configuration file parser instead. Python
comes with one, see the section "13.2 Configuration file parser" at
http://docs.python.org/2/library/, which can both read and write simple
configuration files.


yes I will use it


I should also mention that I use Python 3.. so some of the solutions I
came across are not compatible...


No you don't, Above code clearly uses a print statement instead of a
print function. :P


Yes i do :) i just did not c/p code from my script but from some webpage 
:)) i have print (config["value1"])



Anyhow, concerning the link above, replace the 2 with
a 3 and skip to section 14.2.


thank you i am using configparser... the only problem as i mention in 
another post is that it reads lists as string... so some additional 
parsing is necessary..


thanks!
--
http://mail.python.org/mailman/listinfo/python-list


Re: editing conf file

2012-11-16 Thread chip9munk

On 11/16/2012 2:04 PM, Thomas Bach wrote:

On Fri, Nov 16, 2012 at 01:48:49PM +0100, chip9munk wrote:

configparser has four functions: get, getboolean, getfloat and getint.

how do I get list from cfg file?!


AFAIK you have to parse the list yourself. Something like

my_list = [ s.strip() for s in cp.get('section', 'option').split(',') ]

if you use a comma as a separator.


yes i guess this is needed, thanks!


Have a look at YAML if this is not enough for you, as I think lists
are supported there. Haven't had a look myself though, yet.



I will check it out!

Thank you!


--
http://mail.python.org/mailman/listinfo/python-list


django - adding a button with parallel functionality

2013-12-08 Thread chip9munk
Hi all! I'll try to be clear and brief.

I have created a django project some months ago. It is an online survey.
Now I want to add a button that when pressed adds something to a database, but 
does not change any existing functionalities. 

Brief explanation:
button will always be present at the pages with survey questions,
when pressed it will simply add a page number (at which page user decided to 
press the button) to a database, but the user will continue with the survey as 
normal.
(when the button is pressed, the view, template, questions at hand should not 
change. Nothing changes for the survey subject!)

My question is how to simply add this button without interfering with the 
survey.
I do not need detailed instructions with models, views, templates, etc. just 
brief idea if it is possible to do that without adding new view, reloading 
view, adding forms etc...

(If anyone is interested.. the button will be used to mark when (at which page) 
the user gets bored with questions, it is for the pilot testing of the survey. 
pilot users will press the button but then continue with the survey.)

Thanks in advance!

Best,

chip
-- 
https://mail.python.org/mailman/listinfo/python-list


csv read _csv.Error: line contains NULL byte

2014-03-21 Thread chip9munk
Hi all!

I am reading from a huge csv file (> 20 Gb), so I have to read line by line:

for i, row in enumerate(input_reader):
  #  and I do something on each row

Everything works fine until i get to a row with some strange symbols "0I`00�^"
at that point I get an error: _csv.Error: line contains NULL byte

How can i skip such row and continue going, or "decipher" it in some way?

I have tried :
csvFile = open(input_file_path, 'rb')
csvFile = open(input_file_path, 'rU')
csvFile = open(input_file_path, 'r')

and nothing works.

if I do:

try:
for i, row in enumerate(input_reader):
  #  and I do something on each row
except Exception:
sys.exc_clear() 

i simply stop an that line. I would like to skip it and move on.

Please help!

Best,

Chip Munk
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: csv read _csv.Error: line contains NULL byte

2014-03-21 Thread chip9munk
On Friday, March 21, 2014 2:39:37 PM UTC+1, Tim Golden wrote:

> Without disturbing your existing code too much, you could wrap the
> 
> input_reader in a generator which skips malformed lines. That would look
> 
> something like this:
> 
> 
> 
> def unfussy_reader(reader):
> 
> while True:
> 
> try:
> 
> yield next(reader)
> 
> except csv.Error:
> 
> # log the problem or whatever
> 
> continue


I am sorry I do not understand how to get to each row in this way.

Please could you explain also this:
If I define this function, 
how do I change my for loop to get each row?

Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: csv read _csv.Error: line contains NULL byte

2014-03-21 Thread chip9munk
Ok, I have figured it out:

for i, row in enumerate(unfussy_reader(input_reader): 
  #  and I do something on each row 

Sorry, it is my first "face to face" with generators!

Thank you very much!

Best,
Chip Munk
-- 
https://mail.python.org/mailman/listinfo/python-list


strange array size problem

2013-10-18 Thread chip9munk
Hello everybody!

One strange problem, please help!

I have the following 2D array: users_elements_matrix
numpy.shape(users_elements_matrix) is (100,43)

and array merged_binary_ratings
numpy.shape(merged_binary_ratings) is (100,)

Now,when I run:
numpy.linalg.lstsq(users_elements_matrix, merged_binary_ratings)
i get some ridiculous numbers for coeficients, all are the same and 
1.38946385e+15.

What is really strange is that if I run 
numpy.shape(users_elements_matrix[:,0:42]) 
i get ok numbers.

I tested several thing and have examined the matrix, everything is ok with the 
data.

how is it possible that one additional row (variable in linear regression)
has such a strange impact?!!?

I am loosing my mind here, please help! 

Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: strange array size problem

2013-10-18 Thread chip9munk
one more thing.

the problem is not in the last column, if I use it in regression (only that 
column, or with a few others) I will get the results. But if I use all 43 
columns python breaks!

whhh?!?!?!

thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: strange array size problem

2013-10-18 Thread chip9munk
Interesting!
rank of the whole minus last row
numpy.linalg.matrix_rank(users_elements_matrix[:,0:42]) is 42

but also rank of whole is
numpy.linalg.matrix_rank(users_elements_matrix[:,0:43]) is 42

but what does that mean?!

could you explain briefly what now?

thank you!

On Friday, October 18, 2013 5:44:31 PM UTC+2, Oscar Benjamin wrote:
> On 18 October 2013 16:36,   wrote:
> 
> > one more thing.
> 
> >
> 
> > the problem is not in the last column, if I use it in regression (only that 
> > column, or with a few others) I will get the results. But if I use all 43 
> > columns python breaks!
> 
> 
> 
> Have you tried testing the rank with numpy.linalg.matrix_rank? I'm
> 
> guessing that the extra row makes the matrix singular (up to floating
> 
> point error).
> 
> 
> 
> 
> 
> Oscar
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: strange array size problem

2013-10-18 Thread chip9munk

On 18.10.2013 18:05, Oscar Benjamin wrote:
It means that the additional column is a linear combination of the 
existing columns. This means that your system of equations can contain 
a contradiction. Essentially you're trying to get the least squares 
solution to something like: 3*x + y = 1 1*x + 2*y = 4 1*x + 2*y = 5 # 
Contradicts the equation above Because of floating point error it 
isn't *exactly* a contradiction so you get silly values instead of an 
error. http://en.wikipedia.org/wiki/Rank_(linear_algebra)


I get it, due to the type of data this can be possible and I am sure 
that is the issue.
Now I have to figure out how to solve it, but at least you have 
identified the problem for me.


Thank you very much for clear and prompt solution!

Best
--
https://mail.python.org/mailman/listinfo/python-list


Re: strange array size problem

2013-10-18 Thread chip9munk
On Friday, October 18, 2013 5:37:14 PM UTC+2, Robert Kern wrote:

> The numpy-discussion mailing list is probably the best place to ask. I 
> recommend 
> 
> posting a complete working example (with data) that demonstrates the problem. 
> 
> Use pastebin.com or a similar service if necessary.
> 
> 
> 
>http://www.scipy.org/scipylib/mailing-lists.html


thank you for letting me know. Fortunately, I still got the answer here. 

Best
-- 
https://mail.python.org/mailman/listinfo/python-list