[Tutor] dictionary of lists

2015-06-03 Thread Chris Stinemetz
I am trying to create a dictionary of lists as I read a file. I envision it looking like: {key: [float_type],[string_type]} For the first item in the list I am trying to add the value to the existing value where the key matches but I am getting the following error: Resetting execution engine

Re: [Tutor] string delimiters

2015-06-03 Thread Alan Gauld
On 03/06/15 21:23, richard kappler wrote: hold the phone I have no idea why it worked, would love an explanation, but I changed my previous test script by eliminating for tag in (icdm): This loops over the string assigning the characters i,c,d and m to tag if 'icdm' in line: This

Re: [Tutor] string delimiters

2015-06-03 Thread Alan Gauld
On 03/06/15 20:10, richard kappler wrote: for formatting a string and adding descriptors: test = 'datetimepart1part2part3the_rest' If this is really about parsing dates and times have you looked at the datetime module and its parsing/formatting functions (ie strptime/strftime)? Can I stop

Re: [Tutor] string delimiters

2015-06-03 Thread richard kappler
I was trying to keep it simple, you'd think by now I'd know better. My fault and my apology. It's definitely not all dates and times, the data and character types vary. This is the output from my log parser script which you helped on the other day. there are essentially two types of line: Tue

Re: [Tutor] FTP GET from Variables Stored in File

2015-06-03 Thread Alan Gauld
On 03/06/15 17:49, Eric Grey wrote: declarations in a script. So I have the name of each file (i.e., apple.txt, blue.txt) in a separate seed file that I want the script to read in and treat each line of the seed file as the variable I want to request the FTP GET on. So something like:

Re: [Tutor] string delimiters

2015-06-03 Thread richard kappler
hold the phone I have no idea why it worked, would love an explanation, but I changed my previous test script by eliminating for tag in (icdm): and changing if tag in line to if 'icdm' in line: and it works perfectly! It only iterates over the file once, and the else executes so both

[Tutor] FTP GET from Variables Stored in File

2015-06-03 Thread Eric Grey
I'm fairly new to programming and as a result, Python too. I've been researching the Tutor archives trying to find a solution to my need, however, haven't stumbled across the exact example and are now in information overload. Wondering if I could get some help? I have the need to perform an FTP

Re: [Tutor] dictionary of lists

2015-06-03 Thread Alan Gauld
On 03/06/15 17:39, Chris Stinemetz wrote: I am trying to create a dictionary of lists as I read a file. I envision it looking like: {key: [float_type],[string_type]} Thats not a dictionary of lists. You maybe mean: {key: [[float_type],[string_type]]} Which is a dictionary of lists of lists?

Re: [Tutor] string delimiters

2015-06-03 Thread Alan Gauld
On 03/06/15 21:13, richard kappler wrote: I was trying to keep it simple, you'd think by now I'd know better. My fault and my apology. It's definitely not all dates and times, the data and character types vary. This is the output from my log parser script which you helped on the other day.

Re: [Tutor] string delimiters

2015-06-03 Thread richard kappler
figured that out from your last post, and thank you, now I understand how that works. I thought I was looking for the entire string, not each character. That bit all makes sense now. A descriptor is, for example, for the following part of a string '0032.4' the descriptor would be weight, so the

[Tutor] string delimiters

2015-06-03 Thread richard kappler
for formatting a string and adding descriptors: test = 'datetimepart1part2part3the_rest' newtest = 'date=' + test[0:4] + ' time=' + test[4:8] + ' part1=' + test[8:13] + ' part2=' + test[13:18] + ' part3=' + test[18:23] + ' the rest=' + test[23:] and while this may be ugly, it does what I want

Re: [Tutor] string delimiters

2015-06-03 Thread Alex Kleider
On 2015-06-03 12:53, Alan Gauld wrote: ... If this is really about parsing dates and times have you looked at the datetime module and its parsing/formatting functions (ie strptime/strftime)? I asssume strftime gets its name from 'string from time.' What about strptime? How did that get its

Re: [Tutor] string delimiters

2015-06-03 Thread Cameron Simpson
On 03Jun2015 14:16, Alex Kleider aklei...@sonic.net wrote: On 2015-06-03 12:53, Alan Gauld wrote: ... If this is really about parsing dates and times have you looked at the datetime module and its parsing/formatting functions (ie strptime/strftime)? I asssume strftime gets its name from

Re: [Tutor] string delimiters

2015-06-03 Thread Alex Kleider
On 2015-06-03 15:13, Mark Lawrence wrote: 'f' for format, 'p' for parse, having originally come from plain old C. More here https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior So I was wrong about the 'f' as well as having no clue about the 'p'! Thank you very much

Re: [Tutor] string delimiters

2015-06-03 Thread richard kappler
Perhaps the better way for me to have asked this question would have been: How can I find the location within a string of every instance of a character such as ']'? regards, Richard On Wed, Jun 3, 2015 at 5:16 PM, Alex Kleider aklei...@sonic.net wrote: On 2015-06-03 12:53, Alan Gauld wrote:

Re: [Tutor] string delimiters

2015-06-03 Thread Mark Lawrence
On 03/06/2015 22:16, Alex Kleider wrote: On 2015-06-03 12:53, Alan Gauld wrote: ... If this is really about parsing dates and times have you looked at the datetime module and its parsing/formatting functions (ie strptime/strftime)? I asssume strftime gets its name from 'string from time.'

Re: [Tutor] string delimiters

2015-06-03 Thread Alan Gauld
On 03/06/15 22:16, Alex Kleider wrote: On 2015-06-03 12:53, Alan Gauld wrote: ... If this is really about parsing dates and times have you looked at the datetime module and its parsing/formatting functions (ie strptime/strftime)? I asssume strftime gets its name from 'string from time.' What

Re: [Tutor] string delimiters

2015-06-03 Thread Cameron Simpson
On 03Jun2015 17:35, richard kappler richkapp...@gmail.com wrote: Perhaps the better way for me to have asked this question would have been: How can I find the location within a string of every instance of a character such as ']'? With the str.find method! s = 'a]b]c' pos = s.find(']')

Re: [Tutor] string delimiters

2015-06-03 Thread Peter Otten
richard kappler wrote: Perhaps the better way for me to have asked this question would have been: How can I find the location within a string of every instance of a character such as ']'? import re s = alpha]beta]gamma]delta [m.start() for m in re.finditer(r], s)] [5, 10, 16] But do you

Re: [Tutor] dictionary of lists

2015-06-03 Thread Chris Stinemetz
Resetting execution engine Running C:\Users\cs062x\Desktop\python\projects\PanHandle\PanHandle\PanHandle.py The Python REPL process has exited That's slightly unusual. How are you running this? I am running it with Microsoft Visual Studio Community 2013 using Python Tools for Visual

Re: [Tutor] unittest with random population data

2015-06-03 Thread Cameron Simpson
[ I've taken this discussion back to the tutor list. - Cameron ] On 01Jun2015 18:14, Sydney Shall s.sh...@virginmedia.com wrote: On 31/05/2015 03:00, Cameron Simpson wrote: You say that your results are all rather close, consistent with the sigma value I have chosen for the spread of my

Re: [Tutor] Trouble using bioread to convert files from .acq to .mat

2015-06-03 Thread Ila Kumar
Laura, that was it! Thank you so much. However, now I am confused about what I need to type into the Command prompt window (on a 64-bit windows computer, using python 2.7) in order to convert a folder of data files. Does anyone know the proper code to do this? On Tue, Jun 2, 2015 at 4:45 AM,

Re: [Tutor] Trouble using bioread to convert files from .acq to .mat

2015-06-03 Thread Alan Gauld
On 03/06/15 13:57, Ila Kumar wrote: However, now I am confused about what I need to type into the Command prompt window (on a 64-bit windows computer, using python 2.7) in order to convert a folder of data files. Does anyone know the proper code to do this? You will need to give us a lot more

[Tutor] line iteration in a file

2015-06-03 Thread richard kappler
Figured out the string delimiters problem, thanks for all the help. Now I've run into another. I've used the re.finditer that I think it was Peter suggested. So I have: for line in file: s = line t = [m.start() for m in re.finditer(r], s)] q = len(t) which

Re: [Tutor] line iteration in a file

2015-06-03 Thread Cameron Simpson
On 03Jun2015 22:37, richard kappler richkapp...@gmail.com wrote: Figured out the string delimiters problem, thanks for all the help. Now I've run into another. I've used the re.finditer that I think it was Peter suggested. So I have: for line in file: s = line t =