Re: [Tutor] How to list/process files with identical character strings

2014-06-26 Thread Steven D'Aprano
On Wed, Jun 25, 2014 at 09:47:07PM -0700, Alex Kleider wrote: > Thanks for elucidating this. I didn't know that "several thousand" > would still be considered a small number. On a server, desktop, laptop or notepad, several thousand is not many. My computer can generate a dict with a million i

Re: [Tutor] How to list/process files with identical character strings

2014-06-25 Thread Alex Kleider
On 2014-06-25 00:35, Wolfgang Maier wrote: On 25.06.2014 00:55, Alex Kleider wrote: I was surprised that the use of dictionaries was suggested, especially since we were told there were many many files. The OP was talking about several thousands of files, which is, of course, too many for man

Re: [Tutor] How to list/process files with identical character strings

2014-06-25 Thread Wolfgang Maier
On 25.06.2014 00:55, Alex Kleider wrote: I was surprised that the use of dictionaries was suggested, especially since we were told there were many many files. The OP was talking about several thousands of files, which is, of course, too many for manual processing, but is far from an impressi

Re: [Tutor] How to list/process files with identical character strings

2014-06-25 Thread Peter Otten
Alex Kleider wrote: > On 2014-06-24 14:01, mark murphy wrote: >> Hi Danny, Marc, Peter and Alex, >> >> Thanks for the responses! Very much appreciated. >> >> I will take these pointers and see what I can pull together. >> >> Thanks again to all of you for taking the time to help! > > > Assum

Re: [Tutor] How to list/process files with identical character strings

2014-06-24 Thread Alex Kleider
On 2014-06-24 14:01, mark murphy wrote: Hi Danny, Marc, Peter and Alex, Thanks for the responses! Very much appreciated. I will take these pointers and see what I can pull together. Thanks again to all of you for taking the time to help! Assuming your files are ordered and therefore one's

Re: [Tutor] How to list/process files with identical character strings

2014-06-24 Thread Mark Lawrence
On 24/06/2014 22:01, mark murphy wrote: Hi Danny, Marc, Peter and Alex, Thanks for the responses! Very much appreciated. I will take these pointers and see what I can pull together. Thanks again to all of you for taking the time to help! Cheers, Mark On Tue, Jun 24, 2014 at 4:39 PM, Danny

Re: [Tutor] How to list/process files with identical character strings

2014-06-24 Thread mark murphy
Hi Danny, Marc, Peter and Alex, Thanks for the responses! Very much appreciated. I will take these pointers and see what I can pull together. Thanks again to all of you for taking the time to help! Cheers, Mark On Tue, Jun 24, 2014 at 4:39 PM, Danny Yoo wrote: > The sorting approach sounds

Re: [Tutor] How to list/process files with identical character strings

2014-06-24 Thread Danny Yoo
The sorting approach sounds reasonable. We might even couple it with itertools.groupby() to get the consecutive grouping done for us. https://docs.python.org/2/library/itertools.html#itertools.groupby For example, the following demonstrates that there's a lot that the library will do for us

Re: [Tutor] How to list/process files with identical character strings

2014-06-24 Thread Marc Tompkins
On Tue, Jun 24, 2014 at 1:02 PM, Peter Otten <__pete...@web.de> wrote: > Sorting is probably the approach that is easiest to understand, but an > alternative would be to put the files into a dict that maps the 8-char > prefix to a list of files with that prefix: > I was debating the virtues of th

Re: [Tutor] How to list/process files with identical character strings

2014-06-24 Thread Danny Yoo
Hi Mark, Part of the problem statement sounds a little unusual to me, so I need to push on it to confirm. How do we know that there are only two files at a time that we need to manage? The naming convention described in the problem: --- The naming convention of the files is as follows: TDDD

Re: [Tutor] How to list/process files with identical character strings

2014-06-24 Thread Peter Otten
Peter Otten wrote: > for fileset in days.values(): > if len(fileset) > 1: > # process only the list with one or more files That should have been # process only the lists with two or more files > print("merging", fileset) __

Re: [Tutor] How to list/process files with identical character strings

2014-06-24 Thread Peter Otten
mark murphy wrote: > Hello Python Tutor Community, > > This is my first post and I am just getting started with Python, so I > apologize in advance for any lack of etiquette. > > I have a directory of several thousand daily satellite images that I need > to process. Approximately 300 of these i

Re: [Tutor] How to list/process files with identical character strings

2014-06-24 Thread Marc Tompkins
On Tue, Jun 24, 2014 at 8:34 AM, mark murphy wrote: > What I hope to be able to do is scan the directory, and for each instance > where there are two files where the first 8 characters (TDDD) are > identical, run a process on those two files and place the output (named > TDDD) in a new

Re: [Tutor] How to list/process files with identical character strings

2014-06-24 Thread Alex Kleider
On 2014-06-24 08:34, mark murphy wrote: Hello Python Tutor Community, The actual processing part should be easy enough for me to figure out. The part about finding the split files (each pair of files with the same first 8 characters) and setting those up to be processed is way beyond me. I

[Tutor] How to list/process files with identical character strings

2014-06-24 Thread mark murphy
Hello Python Tutor Community, This is my first post and I am just getting started with Python, so I apologize in advance for any lack of etiquette. I have a directory of several thousand daily satellite images that I need to process. Approximately 300 of these images are split in half, so in jus