Have you tried reading in the entire file? Not practical for massive files I know...
f = file('filename', 'r').readlines()
print f[linenumber]
you can also iterate over the file line by line:
for l in f:
print l
May use lots of memory if you have a BIG file - but it sure is quick.
from time import strptime
str = 'jdhgjkdfhgjsdhgklhsdljSF Jun 23 2006'
try:
MyDate = strptime(str[-11:], '%b %d %Y')
ValidDate = 1
except:
ValidDate = 0
if str[-14:-12]=='SF' and ValidDate:
print 'string is of correct format'
else:
print 'string is NOT correct'
Hope this works for you.
Peter
I would like to use PHP to extract data from MYSQL and have it stored in XML format in much the same way as a dot net dataset stored data from a database.
The reason being I want to use XSLT to format my data for display.
Does anyone know if this is possible and if so could they point me in...
Hi All,
I have two tables and I want to insert data from them into a third table.
Question:
Am I better to write two inserts statements e.g.
INSERT INTO table3 (field1, field2) SELECT field1, field2 FROM table1
and
INSERT INTO table3 (field1, field2) SELECT field1, field2 FROM table2
OR one...
Hi Guys,
Anyone know whis of these will be faster:
@ASWN is a DECIMAL(18,6)
@ID is an INT
IF @ASWN > 0
UPDATE table SET field1=@ASWN WHERE ID=@ID
or
UPDATE table SET field1=@ASWN WHERE ID=@ID AND @ASWN > 0
Logically they are the same:
The first results in the execution of one or two...
Y'all prolly know this, but having just found out for myself I thought I'd share a performance snippet.
I needed to create a running total - found the SQL for that okay - but the performance was pants, so with a bit of fiddling ...
My Tip (works for me anyway).
1) SELECT the data into a temp...
Hi all,
For a purple star can anyone tell me if there is a public DTD for describing a Client's information including transaction history (cash and stocks)?
I really don't want to go re-inventing the wheel.
Kind regards
Peter
Hi Nigel,
Thanks for your help - it did start me thinking. Anyway I have now found the problem or should I say "Microsoft design feature".
http://support.microsoft.com/default.aspx?scid=kb;en-us;810474
My tag line is now:
MS Patches and Service packs - they do more than fix bugs.
We used to run SQL7. The tables were in one DB and there were views in another.
I didn't grant any access to the DB with the tables in it and all was well with the world (and my security).
We have moved to SQL2000 and if I employ the same scenario -the views no longer work.
For the views to...
Hi All,
Is it possible to set up permissions so a user can open and see data in a view, but not open and see data in the underlying tables?
I have tried denying access to the tables and granting to the views, but this doesn't work. The overall effect is denial.
If it can be done, can someone...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.