Re: Newbie: do I need to upload in order to access data?

2013-08-11 Thread mulianto
Hi,

Why not try use JavaScript file open to process the Information in client.

It'a a waste of bandwith in client + server side if upload not needed.

Regards,

Mulianto
Http://muliantophang.blogspot.com



Sent from my iPhone

On 11 Agt 2013, at 18:02, Bob Aalsma  wrote:

> Hi Tom,
> 
> OK, thanks.
> 
> The file I'd want to read is a parameter file which contains user specific 
> information. I just need to know the data to guide the actions, no need to 
> store or keep it.
> So I'll just accept the upload, extract the data and then delete the upload.
> Oh well ;)
> 
> Regards,
> Bob
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie: do I need to upload in order to access data?

2013-08-11 Thread Bob Aalsma
Hi Tom,

OK, thanks.

The file I'd want to read is a parameter file which contains user specific 
information. I just need to know the data to guide the actions, no need to 
store or keep it.
So I'll just accept the upload, extract the data and then delete the upload.
Oh well ;)

Regards,
Bob

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie: do I need to upload in order to access data?

2013-08-11 Thread DJ-Tom
Hi Bob


> I'm trying to achieve the following:
>
>- user indicates a file on his/her machine 
>- the program opens the file, reads the data and acts on that
>
>
>
What you want to do is not possible - at least not without client-side 
scripting.

The "program" you refer to is running on your web server, not on the 
machine of the user. 

So before your code can do anything to the users file, it needs to be 
transferred (uploaded) to your server. So there is nothing you can do with 
Django/Python before that.

After that processing, you may give the user a result page with a link to 
the processed file - but from your description I don't know if if this is 
what you want to do.

regards
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Newbie: do I need to upload in order to access data?

2013-08-11 Thread Bob Aalsma
Thanks Nigel.

OK, at least this has stopped me running around in circles and I can continue 
from here.

I would think you can do stuff client side, but this is probably more Python 
and less Django - to be solved in future releases ;)

Regards,
Bob

Op 11 aug. 2013, om 00:10 heeft Nigel Legg  het volgende 
geschreven:

> The file is uploaded - ie it is copied onto the server drive.  
> I don't think you can do stuff client side with Django - beyond my knowledge. 
> 
> Regards,
> Nigel Legg
> 07914 740972
> http://www.trevanianlegg.co.uk
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
> 
> 
> 
> On 10 August 2013 18:04, Bob Aalsma  wrote:
> Thanks Nigel, this looks very promising ;)
> 
> If I interpret your text correctly, this is based on the upload/save example 
> I mentioned.
> I'm really interested in the meaning of parts your closing paragraph:
> "This saves the file in 'media/documents/2013/08/10/datafile.csv'." - I think 
> this means the contents of the file is copied from the user disk to my disk, 
> right? 
> "pointing them to the correct directory and file." - could I not simply point 
> to the original directory and file (on the user's machine) and read the 
> contents from that location?
> 
> Regards,
> Bob
> 
> Op zaterdag 10 augustus 2013 18:39:38 UTC+2 schreef Nigel Legg:
> I've based my process a minimal file upload - I think based on the answer to 
> the link above.  I use:
> models.py:
> class Document(models.Model):
> docfile = models.FileField(upload_to='documents/%Y/%m/%d')
> 
> views.py:
> def list(request):
> # Handle file uploadf
> if request.method == 'POST':
> form = DocumentForm(request.POST, request.FILES)
> if form.is_valid():
> newdoc = Document(docfile = request.FILES['docfile'])
> newdoc.save()
> 
> # Redirect to the document list after POST
> return HttpResponseRedirect(reverse('myproject.myapp.views.list'))
> else:
> form = DocumentForm() # A empty, unbound form
> 
> # Load documents for the list page
> documents = Document.objects.all()
> 
> # Render list page with the documents and the form
> return render_to_response(
> 'myapp/list.html',
> {'documents': documents, 'form': form},
> context_instance=RequestContext(request)
> )
> 
> forms.py:
> class DocumentForm(forms.Form):
> docfile = forms.FileField(
> label='Select a file',
> help_text='max. 42 megabytes'
> )
> 
> This saves the file in 'media/documents/2013/08/10/datafile.csv'.  You can 
> then access this using the normal open() and read() functions, pointing them 
> to the correct directory and file.  As far as I can see, the data remains in 
> the file you upload, but the location and name are stored in the database - 
> in this case, "documents/2013/10/08/datafile.csv". 
> 
> Hope this helps 
> 
> Regards,
> Nigel Legg
> 07914 740972
> http://www.trevanianlegg.co.uk
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
> 
> 
> 
> On 10 August 2013 15:52, Bob Aalsma  wrote:
> Hi,
> 
> I'm trying to achieve the following:
> user indicates a file on his/her machine 
> the program opens the file, reads the data and acts on that
> 
> So far, I can find examples of indicating the file on the user's machine, but 
> this is always combined with saving to database (which I don't want); the 
> clearest example I could find is 
> http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example
> 
> Question 1: is it really necessary to store the data in my database?
> 
> If not, I've not been able to find how to actually open and read the file.
> I've been trying out variations on reading, based on what I could find in the 
> Tutorials and Managing files 
> (https://docs.djangoproject.com/en/1.5/topics/files/ ) but I don't seem to 
> understand how to actually find the path and filename the user would have 
> indicated. I seem to get completely lost in FileField and FieldFile and 
> connected methods 
> 
> Question 2: how do I find the indicated path and filename from the user?
> 
> Regards,
> Bob
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> 
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
> 
> 
>  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to 

Re: Newbie: do I need to upload in order to access data?

2013-08-10 Thread Nigel Legg
The file is uploaded - ie it is copied onto the server drive.
I don't think you can do stuff client side with Django - beyond my
knowledge.

Regards,
Nigel Legg
07914 740972
http://www.trevanianlegg.co.uk
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 10 August 2013 18:04, Bob Aalsma  wrote:

> Thanks Nigel, this looks very promising ;)
>
> If I interpret your text correctly, this is based on the upload/save
> example I mentioned.
> I'm really interested in the meaning of parts your closing paragraph:
>
>- "This saves the file in 'media/documents/2013/08/10/**datafile.csv'."
>- I think this means the contents of the file is copied from the user disk
>to my disk, right?
>- "pointing them to the correct directory and file." - could I not
>simply point to the *original* directory and file (on the user's
>machine) and read the contents from that location?
>
>
> Regards,
> Bob
>
> Op zaterdag 10 augustus 2013 18:39:38 UTC+2 schreef Nigel Legg:
>>
>> I've based my process a minimal file upload - I think based on the answer
>> to the link above.  I use:
>> models.py:
>> class Document(models.Model):
>> docfile = models.FileField(upload_to='**documents/%Y/%m/%d')
>>
>> views.py:
>> def list(request):
>> # Handle file uploadf
>> if request.method == 'POST':
>> form = DocumentForm(request.POST, request.FILES)
>> if form.is_valid():
>> newdoc = Document(docfile = request.FILES['docfile'])
>> newdoc.save()
>>
>> # Redirect to the document list after POST
>> return HttpResponseRedirect(reverse('**
>> myproject.myapp.views.list'))
>> else:
>> form = DocumentForm() # A empty, unbound form
>>
>> # Load documents for the list page
>> documents = Document.objects.all()
>>
>> # Render list page with the documents and the form
>> return render_to_response(
>> 'myapp/list.html',
>> {'documents': documents, 'form': form},
>> context_instance=**RequestContext(request)
>> )
>>
>> forms.py:
>> class DocumentForm(forms.Form):
>> docfile = forms.FileField(
>> label='Select a file',
>> help_text='max. 42 megabytes'
>> )
>>
>> This saves the file in 'media/documents/2013/08/10/**datafile.csv'.  You
>> can then access this using the normal open() and read() functions, pointing
>> them to the correct directory and file.  As far as I can see, the data
>> remains in the file you upload, but the location and name are stored in the
>> database - in this case, "documents/2013/10/08/**datafile.csv".
>>
>> Hope this helps
>>
>> Regards,
>> Nigel Legg
>> 07914 740972
>> http://www.trevanianlegg.co.uk
>> http://twitter.com/nigellegg
>> http://uk.linkedin.com/in/**nigellegg
>>
>>
>>
>> On 10 August 2013 15:52, Bob Aalsma  wrote:
>>
>>> Hi,
>>>
>>> I'm trying to achieve the following:
>>>
>>>- user indicates a file on his/her machine
>>>- the program opens the file, reads the data and acts on that
>>>
>>>
>>> So far, I can find examples of indicating the file on the user's
>>> machine, but this is always combined with saving to database (which I don't
>>> want); the clearest example I could find is http://stackoverflow.com/**
>>> questions/5871730/need-a-**minimal-django-file-upload-**example
>>>
>>> Question 1: is it really necessary to store the data in my database?
>>>
>>> If not, I've not been able to find how to actually open and read the
>>> file.
>>> I've been trying out variations on reading, based on what I could find
>>> in the Tutorials and Managing files (https://docs.djangoproject.**
>>> com/en/1.5/topics/files/)
>>>  but I don't seem to understand how to actually find the path and filename
>>> the user would have indicated. I seem to get completely lost in FileField
>>> and FieldFile and connected methods 
>>>
>>> Question 2: how do I find the indicated path and filename from the user?
>>>
>>> Regards,
>>> Bob
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 

Re: Newbie: do I need to upload in order to access data?

2013-08-10 Thread Bob Aalsma
Thanks Nigel, this looks very promising ;)

If I interpret your text correctly, this is based on the upload/save 
example I mentioned.
I'm really interested in the meaning of parts your closing paragraph:

   - "This saves the file in 'media/documents/2013/08/10/datafile.csv'." - 
   I think this means the contents of the file is copied from the user disk to 
   my disk, right? 
   - "pointing them to the correct directory and file." - could I not 
   simply point to the *original* directory and file (on the user's 
   machine) and read the contents from that location?


Regards,
Bob

Op zaterdag 10 augustus 2013 18:39:38 UTC+2 schreef Nigel Legg:
>
> I've based my process a minimal file upload - I think based on the answer 
> to the link above.  I use:
> models.py:
> class Document(models.Model):
> docfile = models.FileField(upload_to='documents/%Y/%m/%d')
>
> views.py:
> def list(request):
> # Handle file uploadf
> if request.method == 'POST':
> form = DocumentForm(request.POST, request.FILES)
> if form.is_valid():
> newdoc = Document(docfile = request.FILES['docfile'])
> newdoc.save()
>
> # Redirect to the document list after POST
> return 
> HttpResponseRedirect(reverse('myproject.myapp.views.list'))
> else:
> form = DocumentForm() # A empty, unbound form
>
> # Load documents for the list page
> documents = Document.objects.all()
>
> # Render list page with the documents and the form
> return render_to_response(
> 'myapp/list.html',
> {'documents': documents, 'form': form},
> context_instance=RequestContext(request)
> )
>
> forms.py:
> class DocumentForm(forms.Form):
> docfile = forms.FileField(
> label='Select a file',
> help_text='max. 42 megabytes'
> )
>
> This saves the file in 'media/documents/2013/08/10/datafile.csv'.  You can 
> then access this using the normal open() and read() functions, pointing 
> them to the correct directory and file.  As far as I can see, the data 
> remains in the file you upload, but the location and name are stored in the 
> database - in this case, "documents/2013/10/08/datafile.csv". 
>
> Hope this helps 
>
> Regards,
> Nigel Legg
> 07914 740972
> http://www.trevanianlegg.co.uk
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>
>
> On 10 August 2013 15:52, Bob Aalsma wrote:
>
>> Hi,
>>
>> I'm trying to achieve the following:
>>
>>- user indicates a file on his/her machine 
>>- the program opens the file, reads the data and acts on that 
>>
>>
>> So far, I can find examples of indicating the file on the user's machine, 
>> but this is always combined with saving to database (which I don't want); 
>> the clearest example I could find is 
>> http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example
>>
>> Question 1: is it really necessary to store the data in my database?
>>
>> If not, I've not been able to find how to actually open and read the file.
>> I've been trying out variations on reading, based on what I could find in 
>> the Tutorials and Managing files (
>> https://docs.djangoproject.com/en/1.5/topics/files/ ) but I don't seem 
>> to understand how to actually find the path and filename the user would 
>> have indicated. I seem to get completely lost in FileField and FieldFile 
>> and connected methods 
>>
>> Question 2: how do I find the indicated path and filename from the user?
>>
>> Regards,
>> Bob
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Newbie: do I need to upload in order to access data?

2013-08-10 Thread Nigel Legg
I've based my process a minimal file upload - I think based on the answer
to the link above.  I use:
models.py:
class Document(models.Model):
docfile = models.FileField(upload_to='documents/%Y/%m/%d')

views.py:
def list(request):
# Handle file uploadf
if request.method == 'POST':
form = DocumentForm(request.POST, request.FILES)
if form.is_valid():
newdoc = Document(docfile = request.FILES['docfile'])
newdoc.save()

# Redirect to the document list after POST
return
HttpResponseRedirect(reverse('myproject.myapp.views.list'))
else:
form = DocumentForm() # A empty, unbound form

# Load documents for the list page
documents = Document.objects.all()

# Render list page with the documents and the form
return render_to_response(
'myapp/list.html',
{'documents': documents, 'form': form},
context_instance=RequestContext(request)
)

forms.py:
class DocumentForm(forms.Form):
docfile = forms.FileField(
label='Select a file',
help_text='max. 42 megabytes'
)

This saves the file in 'media/documents/2013/08/10/datafile.csv'.  You can
then access this using the normal open() and read() functions, pointing
them to the correct directory and file.  As far as I can see, the data
remains in the file you upload, but the location and name are stored in the
database - in this case, "documents/2013/10/08/datafile.csv".

Hope this helps

Regards,
Nigel Legg
07914 740972
http://www.trevanianlegg.co.uk
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 10 August 2013 15:52, Bob Aalsma  wrote:

> Hi,
>
> I'm trying to achieve the following:
>
>- user indicates a file on his/her machine
>- the program opens the file, reads the data and acts on that
>
>
> So far, I can find examples of indicating the file on the user's machine,
> but this is always combined with saving to database (which I don't want);
> the clearest example I could find is
> http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example
>
> Question 1: is it really necessary to store the data in my database?
>
> If not, I've not been able to find how to actually open and read the file.
> I've been trying out variations on reading, based on what I could find in
> the Tutorials and Managing files (
> https://docs.djangoproject.com/en/1.5/topics/files/ ) but I don't seem to
> understand how to actually find the path and filename the user would have
> indicated. I seem to get completely lost in FileField and FieldFile and
> connected methods 
>
> Question 2: how do I find the indicated path and filename from the user?
>
> Regards,
> Bob
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Newbie: do I need to upload in order to access data?

2013-08-10 Thread Bob Aalsma
Hi,

I'm trying to achieve the following:

   - user indicates a file on his/her machine 
   - the program opens the file, reads the data and acts on that


So far, I can find examples of indicating the file on the user's machine, 
but this is always combined with saving to database (which I don't want); 
the clearest example I could find 
is 
http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example

Question 1: is it really necessary to store the data in my database?

If not, I've not been able to find how to actually open and read the file.
I've been trying out variations on reading, based on what I could find in 
the Tutorials and Managing files 
(https://docs.djangoproject.com/en/1.5/topics/files/ ) but I don't seem to 
understand how to actually find the path and filename the user would have 
indicated. I seem to get completely lost in FileField and FieldFile and 
connected methods 

Question 2: how do I find the indicated path and filename from the user?

Regards,
Bob

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.