[Tutor] A Python program to Summarise weather results?

2018-08-30 Thread Matthew Polack
Hi,

We have a spreadsheet from a local weather station.it summarises the
amount of rainfall per day since 1863.

http://www.bom.gov.au/jsp/ncc/cdio/weatherData/av?p_nccObsCode=136&p_display_type=dailyDataFile&p_startYear=1863&p_c=-1249186659&p_stn_num=079028

We'd love to be able to summarise this into years eg. Total rainfall of
1863, 1864 all the way through to 2018.

Would Python be able to do this using the csv file?

Thanks,

Matt




Matthew Polack | Teacher


[image: Emailbanner3.png]

Trinity Drive  |  PO Box 822

Horsham Victoria 3402

p. 03 5382 2529   m. 0402456854

e. matthew.pol...@htlc.vic.edu.au

w. www.htlc.vic.edu.au

-- 
**Disclaimer: *Whilst every attempt has been made to ensure that material 
contained in this email is free from computer viruses or other defects, the 
attached files are provided, and may only be used, on the basis that the 
user assumes all responsibility for use of the material transmitted. This 
email is intended only for the use of the individual or entity named above 
and may contain information that is confidential and privileged. If you are 
not the intended recipient, please note that any dissemination, 
distribution or copying of this email is strictly prohibited. If you have 
received this email in error, please notify us immediately by return email 
or telephone +61 3 5382 2529** and destroy the original message.*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] localhosting

2018-08-30 Thread Roger Lea Scherer
I'm trying to implement a local host. My instructions tell me to type the
following command in the command line, make sure I'm in the "www" folder
(which I am and not a subfolder, although there is a subfolder "cgi-bin")
and then run this:
python3 -m http.server --cgi 8000
I'm running Anaconda in Windows 10. I get an error: 'python3' is not
recognized as an internal or external command, operable program or batch
file.
But this is the folder that I thought Python 3.6 was in.

I tried Windows PowerShell and received this error message: python3 : The
term 'python3' is not recognized as the name of a cmdlet, function, script
file, or operable program.
Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.

So how do I correct this? I suspect python3 isn't in this folder. I know I
have python3 because I run python3.6 shell practically every day. I've
looked in the Program Files folder, came up empty as far as python is
concerned, but I don't know where else to look?

Or if this is not the correct forum, can you please (re)direct me to the
correct one?

Thank you.


-- 
Roger Lea Scherer
623.255.7719

  *Strengths:*
   Input, Strategic,
Responsibility,

Learner, Ideation
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OT: How to automate the setting of file permissions for all files in a collection of programs?

2018-08-30 Thread Alan Gauld via Tutor
On 30/08/18 04:44, boB Stepp wrote:

> good news side we went from the vi editor to Vim/gVim; from Python 2.4
> to 2.7; in addition to Tkinter there is now a Python interface to GTK;
> went from no SQLite to having it; and a few other goodies that

Hooray!!!

> system installed, SCCS (RIP!) went bye-bye with _nothing_ to replace

B.


> 1)  Using CuteFTP copy all of my original working code (Now with
> problems due to the planning software upgrade.) to my windows PC.
> 2)  Put this code under Git version control.

This should be a one-off operation.

> 3)  Create a development branch.
> 4)  FTP this back to Solaris for code repair, testing, etc. 

Have you installed cygwin (or the Microsoft Linux subsystem)
on your PC? If so have you trioed working on your files on
the PC and only ftp'ing the "working" files to Solaris?

At the very least cygwin would allow you to run X Windows
on your PC and display the Solaris programs on your PC screen.
It should also provide tools like rsync and ssh at the PC end.
(As per Camerons mail, rsync is by far the best tool for
syncing file systems across machines)

> This process has changed all of the Unix file permissions 

That is inherent in using version control systems.

> So before I can do anything further I must go through all of these
> files and change their permissions to the values I need them to be.
> This is quite tedious and error prone.  

I'd opt for a shell script based on the find command
You can of course do it with Python but a shell script
is the more obvious tool for this kind of operation.

> If there is a way in this CuteFTP software to maintain file
> permissions in this back-and-forth transferring between a Windows and

I don't know CuteFTP but rsync definitely can. One of
its zillions of options.

> software package in the Solaris environment, I am not allowed to do
> so.  I am not allowed to use Python pip either.  Strange rules ...

Not that odd in a corporate environment, I was still using
Python 1.3 in 2002 for similar reasons on one of our work
servers.

But there is a 50/5-0 chance the latest Solaris upgrade
will have included rsync.

Even if it hasn't, if you can mount a Solaris drive on your
PC then you can still use rsync from your PC (via cygwin).
Is that an option?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] localhosting

2018-08-30 Thread Alan Gauld via Tutor
On 30/08/18 00:09, Roger Lea Scherer wrote:
> I'm trying to implement a local host. My instructions tell me to type the
> following command in the command line, make sure I'm in the "www" folder

So this is not the folder where python3 is installed. (See below)

> python3 -m http.server --cgi 8000

> I'm running Anaconda in Windows 10. I get an error: 'python3' is not
> recognized as an internal or external command, operable program or batch
> file.
> But this is the folder that I thought Python 3.6 was in.

you said you were in www which is not where Python should
be installed.

It is likely that Python is not in your system PATH.
You need to find out where it is installed and add it.
In a standard Python install it would either be in
C:\PROGRAM FILES\PYTHON or
C:\PYTHON

But Anaconda (version please?) could use its own path
such as

C:\ANACONDA\PYTHON

> So how do I correct this? I suspect python3 isn't in this folder. I know I
> have python3 because I run python3.6 shell practically every day. 

How do you run it?
>From a command line or via a menu/shortcut?

> looked in the Program Files folder, came up empty as far as python is
> concerned, but I don't know where else to look?

Try using Windows search tool and look for a file called python*.exe

> Or if this is not the correct forum, can you please (re)direct me to the
> correct one?

This is OK, although you might try the Anaconda folks too since
they will know more about how/where Anaconda installs python
and sets up[ default paths.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A Python program to Summarise weather results?

2018-08-30 Thread Peter Otten
Matthew Polack wrote:

> Hi,
> 
> We have a spreadsheet from a local weather station.it summarises the
> amount of rainfall per day since 1863.
> 
> 
http://www.bom.gov.au/jsp/ncc/cdio/weatherData/av?p_nccObsCode=136&p_display_type=dailyDataFile&p_startYear=1863&p_c=-1249186659&p_stn_num=079028
> 
> We'd love to be able to summarise this into years eg. Total rainfall of
> 1863, 1864 all the way through to 2018.
> 
> Would Python be able to do this using the csv file?

Yes. 

Python has powerful tools to make this concise, like csv.DictReader() and 
itertools.groupby(), or -- even more highlevel -- pandas.

But you want to learn Python, don't you? 

Therefore I recommend that you try to solve this with just open() and a for 
loop to read the lines, and the str.split() method to break the lines into 
fields. With 'if ' you check whether the year has changed so that you 
need to print the current total and reset the total rainfall.

Give it a try, see how far you get, and we'll help you over the obstacles 
once you can present some rudimentary code.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A Python program to Summarise weather results?

2018-08-30 Thread Alan Gauld via Tutor
On 30/08/18 03:56, Matthew Polack wrote:
> Hi,
> 
> We have a spreadsheet from a local weather station.it summarises the
> amount of rainfall per day since 1863.
> 
> http://www.bom.gov.au/jsp/ncc/cdio/weatherData/av?p_nccObsCode=136&p_display_type=dailyDataFile&p_startYear=1863&p_c=-1249186659&p_stn_num=079028
> 
> We'd love to be able to summarise this into years eg. Total rainfall of
> 1863, 1864 all the way through to 2018.
> 
> Would Python be able to do this using the csv file?


Absolutely, the csv module will let you read the data.
How you process it is then up to you. If its only the
year field you want to filter by consider loading it
into a dictionary using the year as the key.

Personally, I'd put it into a SQLite database and
use SQL to do the report generation (either from
Python or via the SQLIte command line tool). That
lets you explore the data in many more interesting
ways.

But learning SQL might be a step too far at this
juncture. :-)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OT: How to automate the setting of file permissions for all files in a collection of programs?

2018-08-30 Thread Cameron Simpson

On 30Aug2018 09:08, Alan Gauld  wrote:

On 30/08/18 04:44, boB Stepp wrote:

[...]

4)  FTP this back to Solaris for code repair, testing, etc.

[...]

This process has changed all of the Unix file permissions


That is inherent in using version control systems.


Not really. I suspect FTP may not be preserving permissions across the transfer 
(no proof though).  But git doesn't preserve file permissions as pat of the 
state.  Personally I use mercurial which does include the permissions in the 
state.


But there's also the issue of Windows permissions versus UNIX permissions.

[...]

If there is a way in this CuteFTP software to maintain file
permissions in this back-and-forth transferring between a Windows and


CuteFTP's web site says it can use SFTP (ssh's ftp-ish protocol, which can 
preserve permissions). https://www.globalscape.com/cuteftp



I don't know CuteFTP but rsync definitely can. One of
its zillions of options.


The option is -p (permissions).


software package in the Solaris environment, I am not allowed to do
so.  I am not allowed to use Python pip either.  Strange rules ...


Not that odd in a corporate environment, I was still using
Python 1.3 in 2002 for similar reasons on one of our work
servers.

But there is a 50/5-0 chance the latest Solaris upgrade
will have included rsync.

Even if it hasn't, if you can mount a Solaris drive on your
PC then you can still use rsync from your PC (via cygwin).
Is that an option?


If he can mount a Solaris drive (NFS or SMB) he can just copy the files :-)

Cheers,
Cameron Simpson 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OT: How to automate the setting of file permissions for all files in a collection of programs?

2018-08-30 Thread Alan Gauld via Tutor
On 30/08/18 10:30, Cameron Simpson wrote:

>> That is inherent in using version control systems.
> 
...> state.  Personally I use mercurial which does include the
permissions in the
> state.

Ah, interesting. I've never found a VC system that preserved
permissions. Usually they zap everything to read-only on
first export. Then change them to read-write when you
check out etc, then back to read-only on checkin. I never
assume anything about permissions from a VC system and
always set them as they should be in the make file
or installer.

> But there's also the issue of Windows permissions versus UNIX permissions.

Very true aqnd that varies by file system too. (FAT v NTFS etc)

> If he can mount a Solaris drive (NFS or SMB) he can just copy the files :-)

Yes, but rsync will ensure only the changed files get copied.
Although I think DOS XCOPY can maybe do that too, which might
be another option...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] localhosting

2018-08-30 Thread Mats Wichmann
On 08/30/2018 02:54 AM, Alan Gauld via Tutor wrote:
> On 30/08/18 00:09, Roger Lea Scherer wrote:
>> I'm trying to implement a local host. My instructions tell me to type the
>> following command in the command line, make sure I'm in the "www" folder
> 
> So this is not the folder where python3 is installed. (See below)
> 
>> python3 -m http.server --cgi 8000
> 
>> I'm running Anaconda in Windows 10. I get an error: 'python3' is not
>> recognized as an internal or external command, operable program or batch
>> file.
>> But this is the folder that I thought Python 3.6 was in.
> 
> you said you were in www which is not where Python should
> be installed.
> 
> It is likely that Python is not in your system PATH.
> You need to find out where it is installed and add it.
> In a standard Python install it would either be in
> C:\PROGRAM FILES\PYTHON or
> C:\PYTHON
> 
> But Anaconda (version please?) could use its own path
> such as
> 
> C:\ANACONDA\PYTHON
> 
>> So how do I correct this? I suspect python3 isn't in this folder. I know I
>> have python3 because I run python3.6 shell practically every day. 
> 
> How do you run it?
>>From a command line or via a menu/shortcut?
> 
>> looked in the Program Files folder, came up empty as far as python is
>> concerned, but I don't know where else to look?

Several things that could help:

you can ask python itself to tell you where it is, since you say python
works for you.

>>> import sys
>>> print(sys.executable)

the standard Windows python defaults to a "user install", so it could be
in a place like

{yourhomdirectory}/AppData/Local/Programs/Python

Anaconda, as Alan says, likely puts it somewhere different.

Python 3 isn't named python3 on Windows unless you take steps to make it
so, it's just called python.  So modify your instructions accordingly.

Also on Windows, if it was installed, there is a separate thing called
the Python Launcher, which lets you run the command "py" which typically
gets put in a place that is always found, and avoids the fiddling with
getting Python itself into your PATH.  But I'm unsure whether the
Anaconda install actually installs that. You could try... just type: py


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] SQL querying

2018-08-30 Thread Rafael Knuth
Can I do SQL querying in Python?
What packages do I need for that purpose? (specifically for mySQL) Thanks.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] SQL querying

2018-08-30 Thread Mats Wichmann
On 08/30/2018 11:41 AM, Rafael Knuth wrote:
> Can I do SQL querying in Python?
> What packages do I need for that purpose? (specifically for mySQL) Thanks.
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
> 

yeah, it works fine.

there are actually some competing options (you wanted one simple
answer?). Oracle has an "official" connector (search for that).  There's
MySQLdb, which I've used a fair bit. There's a pure-python version
called pymysql.  And if you are going to get into advanced uses, there's
a lovely bit of code called SQL Alchemy.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor