Computing desk | ||
---|---|---|
< June 17 | << May | June | Jul >> | June 19 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
List of Ubuntu releases says that Ubuntu releases are named in alphabetical order. How will Ubuntu developers choose codenames when they run out of letters in alphabet? 117.5.4.42 ( talk) 04:36, 18 June 2012 (UTC)
Hi. I use Google Chrome under Windows 7 and my router is SpeedTouch. What should I do to switch to IPv6? Does my router support IPv6? Do I need any new software or hardware? Is the switch done automatically? Help me, please. -- 41.129.120.207 ( talk) 20:53, 18 June 2012 (UTC)
It tells me the following:
Your IPv4 address on the public Internet appears to be 41.129.120.207
Your IPv6 address on the public Internet appears to be 2001:0:4137:9e76:18fa:2c5f:d67e:8730
Your IPv6 service appears to be: Teredo
The World IPv6 Launch day is June 6th, 2012. Good news! Your current browser, on this computer and at this location, are expected to keep working after the Launch. [more info]
You appear to be able to browse the IPv4 Internet only. You will not be able to reach IPv6-only sites.
Your IPv6 connection appears to be using Teredo, a type of IPv4/IPv6 gateway; currently it connects only to direct IP's. Your browser will not be able to go to IPv6 sites by name. This means the current configuration is not useful for browsing IPv6 web sites. [more info]
Your DNS server (possibly run by your ISP) appears to have no access to the IPv6 Internet, or is not configured to use it. This may in the future restrict your ability to reach IPv6-only sites. [more info] Your readiness scores
10/10 for your IPv4 stability and readiness, when publishers offer both IPv4 and IPv6
0/10 for your IPv6 stability and readiness, when publishers are forced to go IPv6 only -- 41.129.120.207 ( talk) 21:55, 18 June 2012 (UTC)
So I have just started learning and using python and I have a question. So I have a text file, something like
1990 10 11 21 15 0.0000
1990 10 11 21 20 0.0000
1990 10 11 21 25 0.0000
1990 10 11 21 30 0.0000
with a lot more rows. The columns are delimited by space representing year, month, day, hour, mins, and seconds. So what I want to do is end up with something like
dtdates = [datetime.datetime(1990,10,11,21,15,0),
datetime.datetime(1990,10,11,21,20,0),
datetime.datetime(1990,10,11,21,25,0),
datetime.datetime(1990,10,11,21,30,0)]
an entire array of datetime objects distributed over rows with the columns being the arguments of datetime. First question, all of the arguments of datetime have to be integers right? I am asking about the seconds because in the ascii text file they are written as floats. Second, what is the fastest way (meaning runtime) to do this in python? I can obviously have a naive double for loop but doesn't seem like a good idea for python. I have thousands of rows to process like this so dtdates at the end will be one giant array consisting datetime objects. Thanks!
- Looking for Wisdom and Insight! (
talk)
22:50, 18 June 2012 (UTC)
#!/usr/bin/python
import datetime
dtdates = []
for line in open('data','r'):
year,month,day,hour,minute,second = line.split()
second = float(second)
ms = (second-int(second))*1000000
dtdates.append(datetime.datetime(int(year),
int(month),
int(day),
int(hour),
int(minute),
int(second),
int(ms)))
dtdates.append(datetime.datetime.strptime(line.strip(), "%Y %m %d %H %M %S.%f"))
Thanks for being prompt but I just realized two things. First the text file has more columns on the right (a total of like 14 but I only need the first six for time) so I suspect the line split thing may not work. Second, I need to read in all columns (because I need them for more processing later) so now instead of reading the time from the text file and datetiming it, I do the following
mydata = numpy.loadtxt('myfile.txt',delimiter=' ') time = mydata[:,0:6]
I think "time" would be an array of arrays? So now the question is, how to go from this above define "time" variable to "dtdates" defined way above? And lastly, is appending the only way to do it? Seems like there should be a faster more efficient approach? If I am reading the entire file, I can know its length so can't I preallocate an array with enough space to hold all the datetime objects and then fill them in? I just don't know the commands to do all this nicely. Thanks again! - Looking for Wisdom and Insight! ( talk) 23:44, 18 June 2012 (UTC)
strptime
alone takes several times longer than that. Also, the input file might be cached in RAM. --
BenRG (
talk)
17:39, 19 June 2012 (UTC)Oh and looking at the second edit, I would actually prefer the condensed version. So can we modify this condensed version to accomodate the changes I described above? It will be much much faster (I know this from past experience in other languages...classic debate for compiled versus interpretative languages). - Looking for Wisdom and Insight! ( talk) 23:47, 18 June 2012 (UTC)
with open('data', 'r') as f:
dtdates = datetime.datetime.strptime(line.strip(), "%Y %m %d %H %M %S.%f")
for line in f
strptime
(or maybe I/O, but see above). dtdates, other_fields = [], []
with open('data', 'r') as f:
for line in f:
year, month, day, hour, minute, second, remainder_of_line = line.split(None, 6)
other_fields.append(remainder_of_line)
# make a datetime object and append it to dtdates, as above
split
should match the number of commas on the left hand side. Or maybe this: with open('data', 'r') as f:
for line in f:
col1to6, col7, col8, ..., col14 = line.rsplit(None, 8)
dtdates.append(datetime.datetime.strptime(col1to6.lstrip(), "%Y %m %d %H %M %S.%f"))
# do whatever with the remaining columns
strptime
against manual datetime
construction. --
BenRG (
talk)
17:39, 19 June 2012 (UTC)Actually it isn't as bad as I thought. I got it working. Thanks again! - Looking for Wisdom and Insight! ( talk) 18:25, 19 June 2012 (UTC)
Computing desk | ||
---|---|---|
< June 17 | << May | June | Jul >> | June 19 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
List of Ubuntu releases says that Ubuntu releases are named in alphabetical order. How will Ubuntu developers choose codenames when they run out of letters in alphabet? 117.5.4.42 ( talk) 04:36, 18 June 2012 (UTC)
Hi. I use Google Chrome under Windows 7 and my router is SpeedTouch. What should I do to switch to IPv6? Does my router support IPv6? Do I need any new software or hardware? Is the switch done automatically? Help me, please. -- 41.129.120.207 ( talk) 20:53, 18 June 2012 (UTC)
It tells me the following:
Your IPv4 address on the public Internet appears to be 41.129.120.207
Your IPv6 address on the public Internet appears to be 2001:0:4137:9e76:18fa:2c5f:d67e:8730
Your IPv6 service appears to be: Teredo
The World IPv6 Launch day is June 6th, 2012. Good news! Your current browser, on this computer and at this location, are expected to keep working after the Launch. [more info]
You appear to be able to browse the IPv4 Internet only. You will not be able to reach IPv6-only sites.
Your IPv6 connection appears to be using Teredo, a type of IPv4/IPv6 gateway; currently it connects only to direct IP's. Your browser will not be able to go to IPv6 sites by name. This means the current configuration is not useful for browsing IPv6 web sites. [more info]
Your DNS server (possibly run by your ISP) appears to have no access to the IPv6 Internet, or is not configured to use it. This may in the future restrict your ability to reach IPv6-only sites. [more info] Your readiness scores
10/10 for your IPv4 stability and readiness, when publishers offer both IPv4 and IPv6
0/10 for your IPv6 stability and readiness, when publishers are forced to go IPv6 only -- 41.129.120.207 ( talk) 21:55, 18 June 2012 (UTC)
So I have just started learning and using python and I have a question. So I have a text file, something like
1990 10 11 21 15 0.0000
1990 10 11 21 20 0.0000
1990 10 11 21 25 0.0000
1990 10 11 21 30 0.0000
with a lot more rows. The columns are delimited by space representing year, month, day, hour, mins, and seconds. So what I want to do is end up with something like
dtdates = [datetime.datetime(1990,10,11,21,15,0),
datetime.datetime(1990,10,11,21,20,0),
datetime.datetime(1990,10,11,21,25,0),
datetime.datetime(1990,10,11,21,30,0)]
an entire array of datetime objects distributed over rows with the columns being the arguments of datetime. First question, all of the arguments of datetime have to be integers right? I am asking about the seconds because in the ascii text file they are written as floats. Second, what is the fastest way (meaning runtime) to do this in python? I can obviously have a naive double for loop but doesn't seem like a good idea for python. I have thousands of rows to process like this so dtdates at the end will be one giant array consisting datetime objects. Thanks!
- Looking for Wisdom and Insight! (
talk)
22:50, 18 June 2012 (UTC)
#!/usr/bin/python
import datetime
dtdates = []
for line in open('data','r'):
year,month,day,hour,minute,second = line.split()
second = float(second)
ms = (second-int(second))*1000000
dtdates.append(datetime.datetime(int(year),
int(month),
int(day),
int(hour),
int(minute),
int(second),
int(ms)))
dtdates.append(datetime.datetime.strptime(line.strip(), "%Y %m %d %H %M %S.%f"))
Thanks for being prompt but I just realized two things. First the text file has more columns on the right (a total of like 14 but I only need the first six for time) so I suspect the line split thing may not work. Second, I need to read in all columns (because I need them for more processing later) so now instead of reading the time from the text file and datetiming it, I do the following
mydata = numpy.loadtxt('myfile.txt',delimiter=' ') time = mydata[:,0:6]
I think "time" would be an array of arrays? So now the question is, how to go from this above define "time" variable to "dtdates" defined way above? And lastly, is appending the only way to do it? Seems like there should be a faster more efficient approach? If I am reading the entire file, I can know its length so can't I preallocate an array with enough space to hold all the datetime objects and then fill them in? I just don't know the commands to do all this nicely. Thanks again! - Looking for Wisdom and Insight! ( talk) 23:44, 18 June 2012 (UTC)
strptime
alone takes several times longer than that. Also, the input file might be cached in RAM. --
BenRG (
talk)
17:39, 19 June 2012 (UTC)Oh and looking at the second edit, I would actually prefer the condensed version. So can we modify this condensed version to accomodate the changes I described above? It will be much much faster (I know this from past experience in other languages...classic debate for compiled versus interpretative languages). - Looking for Wisdom and Insight! ( talk) 23:47, 18 June 2012 (UTC)
with open('data', 'r') as f:
dtdates = datetime.datetime.strptime(line.strip(), "%Y %m %d %H %M %S.%f")
for line in f
strptime
(or maybe I/O, but see above). dtdates, other_fields = [], []
with open('data', 'r') as f:
for line in f:
year, month, day, hour, minute, second, remainder_of_line = line.split(None, 6)
other_fields.append(remainder_of_line)
# make a datetime object and append it to dtdates, as above
split
should match the number of commas on the left hand side. Or maybe this: with open('data', 'r') as f:
for line in f:
col1to6, col7, col8, ..., col14 = line.rsplit(None, 8)
dtdates.append(datetime.datetime.strptime(col1to6.lstrip(), "%Y %m %d %H %M %S.%f"))
# do whatever with the remaining columns
strptime
against manual datetime
construction. --
BenRG (
talk)
17:39, 19 June 2012 (UTC)Actually it isn't as bad as I thought. I got it working. Thanks again! - Looking for Wisdom and Insight! ( talk) 18:25, 19 June 2012 (UTC)