Re: Python Data base help

2016-10-17 Thread Brandon McCaig
(Apologies for the old thread reviving)

On Sun, Oct 09, 2016 at 09:27:11PM +0200, Irmen de Jong wrote:
> What is your 'database'?
> >From the little information you provided it seems that it is just a text 
> >file where
> every drone measurement is on a line. So simply read every line and check if 
> the time
> entered is in that line, then print it.

On the other hand, if your "database" really is just a text file
and you want to find the records that match a strict time string
there's already a fast native utility for this available: grep
(*nix) or findstr (Windows).

The advantage being that you could search for more than just the
time. It's still limited to only textual matches, not smart
matches (e.g., ranges). In the end, a custom program will be more
powerful to process the data.

Alternatively, if the data is a text file and you want to query
it regularly, consider learning a bit about SQL and sqlite3 and
import the data into a "real" database first. Then you'll get the
full expressive power of a query language and the performance
improvements of binary data and indexing (if you tune it right).

Regards,


-- 
Brandon McCaig  
Castopulence Software 
Blog 
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

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


Re: Python Data base help

2016-10-09 Thread breamoreboy
On Sunday, October 9, 2016 at 7:56:57 PM UTC+1, Risat Haque wrote:
> Hey, i have a data base filled with numbers from a recent drone flight. IT 
> contains, alt, long, lat, and time.
> In python, i want to ask the user to put in a time : 
> askTime = (input("Choose a time (HourMinSec):"))
> 
> With this, I need it to search through the entire data base to find that 
> number. 
> 
> ("UTC: 8:58:24 lat: 50.97 long: -114.05  Alt: 1047.40m  SOG: 1.04 km/h") 
> 
> EX: 
> 
> Choose a time (HourMinSec):8:58:24
> Data: UTC: 8:58:24 lat: 50.97 long: -114.05  Alt: 1047.40m  SOG: 1.04 km/h"
> 
> How can I do this?

I'd use strptime[1] to check the input then search your database, whatever that 
may be, based on that.

[1] https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime

Kindest regards.

Mark Lawrence.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Data base help

2016-10-09 Thread Irmen de Jong
On 9-10-2016 20:56, Risat Haque wrote:
> Hey, i have a data base filled with numbers from a recent drone flight. IT 
> contains, alt, long, lat, and time.
> In python, i want to ask the user to put in a time : 
> askTime = (input("Choose a time (HourMinSec):"))
> 
> With this, I need it to search through the entire data base to find that 
> number. 
> 
> ("UTC: 8:58:24 lat: 50.97 long: -114.05  Alt: 1047.40m  SOG: 1.04 km/h") 
> 
> EX: 
> 
> Choose a time (HourMinSec):8:58:24
> Data: UTC: 8:58:24 lat: 50.97 long: -114.05  Alt: 1047.40m  SOG: 1.04 km/h"
> 
> How can I do this? 
> 

What is your 'database'?
>From the little information you provided it seems that it is just a text file 
>where
every drone measurement is on a line. So simply read every line and check if 
the time
entered is in that line, then print it.


Irmen

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


Python Data base help

2016-10-09 Thread Risat Haque
Hey, i have a data base filled with numbers from a recent drone flight. IT 
contains, alt, long, lat, and time.
In python, i want to ask the user to put in a time : 
askTime = (input("Choose a time (HourMinSec):"))

With this, I need it to search through the entire data base to find that 
number. 

("UTC: 8:58:24 lat: 50.97 long: -114.05  Alt: 1047.40m  SOG: 1.04 km/h") 

EX: 

Choose a time (HourMinSec):8:58:24
Data: UTC: 8:58:24 lat: 50.97 long: -114.05  Alt: 1047.40m  SOG: 1.04 km/h"

How can I do this? 
-- 
https://mail.python.org/mailman/listinfo/python-list