Re: Working around multiple files in a folder

2016-12-08 Thread Veek M
Emile van Sebille wrote: > On 11/21/2016 11:27 AM, subhabangal...@gmail.com wrote: >> I have a python script where I am trying to read from a list of files >> in a folder and trying to process something. As I try to take out the >> output I am presently appending to a list. >> >> But I am trying t

Re: Working around multiple files in a folder

2016-11-21 Thread Emile van Sebille
On 11/21/2016 11:27 AM, subhabangal...@gmail.com wrote: I have a python script where I am trying to read from a list of files in a folder and trying to process something. As I try to take out the output I am presently appending to a list. But I am trying to write the result of individual files

Working around multiple files in a folder

2016-11-21 Thread subhabangalore
I have a python script where I am trying to read from a list of files in a folder and trying to process something. As I try to take out the output I am presently appending to a list. But I am trying to write the result of individual files in individual list or files. The script is as follows:

RE: Multiple files reading

2016-06-14 Thread Joaquin Alzola
> What I meant was that you would have a dict of dicts, where the key was the > country: Thanks MRAB I could not see that solution. That save me a lot of lines of code. Certainly my previous solution also manage to do that but yours is more clean-code wise. This email is confidential and may be

Re: Multiple files reading

2016-06-14 Thread MRAB
On 2016-06-14 21:06, Joaquin Alzola wrote: > >> The dictionary that I am using in the classes: > >> {'Country':'Empty','Service':'Empty','TimeStamp':'Empty','Ocg':'see3', > >> 'DiameterCodes':{'2001':0,'4010':0,'4012':0,'4998':0,'4999':0,'5007':0 > >> ,'5012':0}} > >> > >> Wanted help from your si

RE: Multiple files reading

2016-06-14 Thread Joaquin Alzola
>> The dictionary that I am using in the classes: >> {'Country':'Empty','Service':'Empty','TimeStamp':'Empty','Ocg':'see3', >> 'DiameterCodes':{'2001':0,'4010':0,'4012':0,'4998':0,'4999':0,'5007':0 >> ,'5012':0}} >> >> Wanted help from your side on how to focus this just because I want to read >>

Re: Multiple files reading

2016-06-14 Thread MRAB
On 2016-06-14 17:53, Joaquin Alzola wrote: Hi Guys I am doing program that reads into a directory for the files that were created the last 5 mins. (working) Inside those files there are 242 fields in each line separated by | (pipe). Each file has about 5k records and there are about 5 files

Multiple files reading

2016-06-14 Thread Joaquin Alzola
Hi Guys I am doing program that reads into a directory for the files that were created the last 5 mins. (working) Inside those files there are 242 fields in each line separated by | (pipe). Each file has about 5k records and there are about 5 files per 5 mins. I will look for field 29 and 200

Re: Spread a class over multiple files

2016-06-06 Thread dieter
Mark Summerfield writes: > Sometimes I want to spread a class over multiple files. When I run into such a use case, I use (multiple) inheritance -- with "mixin class"es. Each "mixin class" handles some important aspect and is only loosely coupled with maybe a common b

Re: Spreading a class over multiple files

2016-06-05 Thread Terry Reedy
On 6/5/2016 2:55 AM, Mark Summerfield wrote: Sometimes I want to spread a class over multiple files. My experience with trying to work with two do-all classes in idlelib has engendered a dislike for such. It is hard to find things in a kitchen-sink class. To switch IDLE from being a multi

Re: Spreading a class over multiple files

2016-06-05 Thread Steven D'Aprano
iple inheritance, mixins and traits. See links here: https://mail.python.org/pipermail/python-list/2016-June/709808.html To my mind, if you have to split a class over multiple files, it probably does too much. The "God Class" that Peter referred to is an anti-pattern: https://en.wikipedia.o

Re: Spreading a class over multiple files

2016-06-05 Thread Mark Summerfield
You're quite right! For some reason I have a blind-spot about mixins, but they are the perfect solution. Thanks:-) -- https://mail.python.org/mailman/listinfo/python-list

Re: Spreading a class over multiple files

2016-06-05 Thread Peter Otten
Mark Summerfield wrote: > Sometimes I want to spread a class over multiple files. > > My primary use case is when I create a "Model" class to reflect an entire > SQL database. I want a model instance to provide a single point of access > to > the database, but the d

Re: Spreading a class over multiple files

2016-06-05 Thread Gary Herron
On 06/04/2016 11:55 PM, Mark Summerfield wrote: Sometimes I want to spread a class over multiple files. There’s and easy way to do this in Python using what's called a Mixin class and (multiple) inheritance: (See https://en.wikipedia.org/wiki/Mixin for more information.) In one file

Spreading a class over multiple files

2016-06-05 Thread Mark Summerfield
Sometimes I want to spread a class over multiple files. My primary use case is when I create a "Model" class to reflect an entire SQL database. I want a model instance to provide a single point of access to the database, but the database has many tables each requiring its own meth

Spread a class over multiple files

2016-06-04 Thread Mark Summerfield
Sometimes I want to spread a class over multiple files. My primary use case is when I create a "Model" class to reflect an entire SQL database. I want a model instance to provide a single point of access to the database, but the database has many tables each requiring its own met

Re: Opening Multiple files at one time

2015-04-22 Thread subhabrata . banerji
On Monday, April 20, 2015 at 5:30:15 PM UTC+5:30, subhabrat...@gmail.com wrote: > Dear Group, > > I am trying to open multiple files at one time. > I am trying to do it as, > > for item in [ "one", "two", "three" ]: >f = open (item

Re: Opening Multiple files at one time

2015-04-22 Thread Felix Dietrich
subhabrata.bane...@gmail.com writes: > Dear Group, > > I am trying to open multiple files at one time. > I am trying to do it as, > > for item in [ "one", "two", "three" ]: >f = open (item + "world.txt", "w") >

Re: Opening Multiple files at one time

2015-04-21 Thread Dave Angel
On 04/21/2015 03:56 AM, subhabrata.bane...@gmail.com wrote: Yes. They do not. They are opening one by one. I have some big chunk of data I am getting by crawling etc. now as I run the code it is fetching data. I am trying to fetch the data from various sites. The contents of the file are gettin

Re: Opening Multiple files at one time

2015-04-21 Thread subhabrata . banerji
On Tuesday, April 21, 2015 at 4:20:16 AM UTC+5:30, Dave Angel wrote: > On 04/20/2015 07:59 AM, wrote: > > Dear Group, > > > > I am trying to open multiple files at one time. > > I am trying to do it as, > > > > for item in [ "one", "two&quo

Re: Opening Multiple files at one time

2015-04-20 Thread Dave Angel
On 04/20/2015 07:59 AM, subhabrata.bane...@gmail.com wrote: Dear Group, I am trying to open multiple files at one time. I am trying to do it as, for item in [ "one", "two", "three" ]: f = open (item + "world.txt", "w") f.clos

Re: Opening Multiple files at one time

2015-04-20 Thread sohcahtoa82
On Monday, April 20, 2015 at 5:00:15 AM UTC-7, subhabrat...@gmail.com wrote: > Dear Group, > > I am trying to open multiple files at one time. > I am trying to do it as, > > for item in [ "one", "two", "three" ]: >f = open (item + &qu

Opening Multiple files at one time

2015-04-20 Thread subhabrata . banerji
Dear Group, I am trying to open multiple files at one time. I am trying to do it as, for item in [ "one", "two", "three" ]: f = open (item + "world.txt", "w") f.close() This is fine. But I was looking if I do not know the numb

Re: Writing Multiple files at a times

2014-06-30 Thread Denis McMahon
On Mon, 30 Jun 2014 12:23:08 -0700, subhabangalore wrote: > Thank you for your kind suggestion. But I am not being able to sort out, > "fp = open( "scraped/body{:0>5d}.htm".format( n ), "w" ) " > please suggest. look up the python manual for string.format() and open() functions. The line indicat

Re: Writing Multiple files at a times

2014-06-30 Thread subhabangalore
On Sunday, June 29, 2014 4:19:27 PM UTC+5:30, subhaba...@gmail.com wrote: > Dear Group, > > > > I am trying to crawl multiple URLs. As they are coming I want to write them > as string, as they are coming, preferably in a queue. > > > > If any one of the esteemed members of the group may kin

Re: Writing Multiple files at a times

2014-06-29 Thread Denis McMahon
On Sun, 29 Jun 2014 10:32:00 -0700, subhabangalore wrote: > I am opening multiple URLs with urllib.open, now one Url has huge html > source files, like that each one has. As these files are read I am > trying to concatenate them and put in one txt file as string. > From this big txt file I am tryi

Re: Writing Multiple files at a times

2014-06-29 Thread subhabangalore
As they are coming I want to write > > > them > > > > as string, as they are coming, preferably in a queue. > > > > > > > > If any one of the esteemed members of the group may kindly help. > > > > > > > > > >

Re: Writing Multiple files at a times

2014-06-29 Thread Roy Smith
ne of the esteemed members of the group may kindly help. > > > > >From your subject line, it appears you want to keep multiple files open, > >and write to each in an arbitrary order. That's no problem, up to the > >operating system limits. Define a class that

Re:Writing Multiple files at a times

2014-06-29 Thread Dave Angel
m your subject line, it appears you want to keep multiple files open, and >write to each in an arbitrary order. That's no problem, up to the operating >system limits. Define a class that holds the URL information and for each >instance, add an attribute for an output file han

Re: Writing Multiple files at a times

2014-06-29 Thread Mark Lawrence
On 29/06/2014 11:49, subhabangal...@gmail.com wrote: Dear Group, I am trying to crawl multiple URLs. As they are coming I want to write them as string, as they are coming, preferably in a queue. If any one of the esteemed members of the group may kindly help. Regards, Subhabrata Banerjee.

Writing Multiple files at a times

2014-06-29 Thread subhabangalore
Dear Group, I am trying to crawl multiple URLs. As they are coming I want to write them as string, as they are coming, preferably in a queue. If any one of the esteemed members of the group may kindly help. Regards, Subhabrata Banerjee. -- https://mail.python.org/mailman/listinfo/python-list

Re: Downloading multiple files based on info extracted from CSV

2013-12-16 Thread Matt Graves
On Thursday, December 12, 2013 5:20:59 PM UTC-5, Chris Angelico wrote: > import urllib > > import csv > > > > # You actually could get away with not using a with > > # block here, but may as well keep it for best practice > > with open('clients.csv') as f: > > for client in csv.reader(f

Re: Downloading multiple files based on info extracted from CSV

2013-12-12 Thread John Gordon
In <88346903-2af8-48cd-9829-37cedb717...@googlegroups.com> Matt Graves writes: > import urllib > import csv > urls = [] > clientname = [] > ###This will set column 7 to be a list of urls > with open('clients.csv', 'r') as f: > reader = csv.reader(f) > for column in reader: > url

Re: Downloading multiple files based on info extracted from CSV

2013-12-12 Thread Chris Angelico
On Fri, Dec 13, 2013 at 8:43 AM, Matt Graves wrote: > ###This SHOULD plug in the URL for F, and the client name for G. > def downloadFile(urls, clientname): > urllib.urlretrieve(f, "%g.csv") % clientname > > downloadFile(f,g) > > When I run it, I get : AttributeError: 'file' object has no attr

Re: Downloading multiple files based on info extracted from CSV

2013-12-12 Thread Mark Lawrence
On 12/12/2013 21:43, Matt Graves wrote: I have a CSV file containing a bunch of URLs I have to download a file from for clients (Column 7) and the clients names (Column 0) I tried making a script to go down the .csv file and just download each file from column 7, and save the file as [clientna

Downloading multiple files based on info extracted from CSV

2013-12-12 Thread Matt Graves
I have a CSV file containing a bunch of URLs I have to download a file from for clients (Column 7) and the clients names (Column 0) I tried making a script to go down the .csv file and just download each file from column 7, and save the file as [clientname].csv I am relatively new to python, so

Re: How Do I get my Python script to attach multiple files and send as a single email

2013-08-08 Thread Joel Goldstick
On Thu, Aug 8, 2013 at 3:19 PM, Gary Herron wrote: > On 08/08/2013 12:05 PM, wachk...@gmail.com wrote: >> >> I have a dilemma I cant figure out how to send multiple files as an >> attachment to my email using this script. I can only send a single file >> attachment .

Re: How Do I get my Python script to attach multiple files and send as a single email

2013-08-08 Thread Ian Kelly
On Thu, Aug 8, 2013 at 1:05 PM, wrote: > I have a dilemma I cant figure out how to send multiple files as an > attachment to my email using this script. I can only send a single file > attachment . Help!!! Here is my script. You just need to repeat part3 for each attachment.

Re: How Do I get my Python script to attach multiple files and send as a single email

2013-08-08 Thread Gary Herron
On 08/08/2013 12:05 PM, wachk...@gmail.com wrote: I have a dilemma I cant figure out how to send multiple files as an attachment to my email using this script. I can only send a single file attachment . Help!!! Here is my script. All filename's are txt files. There is a standard P

How Do I get my Python script to attach multiple files and send as a single email

2013-08-08 Thread wachkama
I have a dilemma I cant figure out how to send multiple files as an attachment to my email using this script. I can only send a single file attachment . Help!!! Here is my script. All filename's are txt files. fo = with open(filename,'rb') fo1 = open(filename2,'rb')

Re: ftp - delete multiple files of same type

2013-02-05 Thread chris . annin
> > > im trying to delete all text files from an ftp directory. is there a way to > > delete multiple files of the same extension? > > > > > > I came up with the following code below which works but I have to append > > the string because ftp.nlst re

Re: ftp - delete multiple files of same type

2013-02-05 Thread MRAB
On 2013-02-05 17:29, chris.an...@gmail.com wrote: im trying to delete all text files from an ftp directory. is there a way to delete multiple files of the same extension? I came up with the following code below which works but I have to append the string because ftp.nlst returns: "

Re: ftp - delete multiple files of same type

2013-02-05 Thread Dave Angel
On 02/05/2013 12:29 PM, chris.an...@gmail.com wrote: im trying to delete all text files from an ftp directory. is there a way to delete multiple files of the same extension? I came up with the following code below which works but I have to append the string because ftp.nlst returns: "

ftp - delete multiple files of same type

2013-02-05 Thread chris . annin
im trying to delete all text files from an ftp directory. is there a way to delete multiple files of the same extension? I came up with the following code below which works but I have to append the string because ftp.nlst returns: "-rwx-- 1 user group 0 Feb 04 15:57 New Text Documen

Re: Split single file into multiple files based on patterns

2012-10-24 Thread Peter Otten
130 3.199000 > A1980KK18700010 186 3366 4.78 > A1980KK18700010 30 186 1.285000 > A1980KK18700010 30 185 4.395000 > A1980KK18700010 185 186 9.00 > A1980KK18700010 25 30 3.493000 > > I want to split the file and get multiple files like A1980JE3937.txt > and A1980KK1870

Re: Split single file into multiple files based on patterns

2012-10-24 Thread David Hutto
On Wed, Oct 24, 2012 at 3:52 AM, Steven D'Aprano wrote: > On Tue, 23 Oct 2012 20:01:03 -0700, satyam wrote: > >> I have a text file like this >> >> A1980JE3937 2732 4195 12.527000 > [...] > >> I want to split the file and get multiple files like A1980

Re: Split single file into multiple files based on patterns

2012-10-24 Thread Steven D'Aprano
On Tue, 23 Oct 2012 20:01:03 -0700, satyam wrote: > I have a text file like this > > A1980JE3937 2732 4195 12.527000 [...] > I want to split the file and get multiple files like A1980JE3937.txt > and A1980KK18700010.txt, where each file will contain column2, 3 and 4

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Mark Lawrence
file and get multiple files like A1980JE3937.txt and A1980KK18700010.txt, where each file will contain column2, 3 and 4. Sorry for being completely off-topic here, but awk has a very convenient feature to deal with this. Simply use: awk '{ print $2,$3,$4 > $1".txt"; }&#

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Alain Ketterlin
satyam writes: > I have a text file like this > > A1980JE3937 2732 4195 12.527000 > A1980JE3937 3465 9720 22.00 > A1980JE3937 2732 9720 18.00 > A1980KK18700010 130 303 4.985000 > A1980KK18700010 7 4915 0.435000 [...] > I want to split the file and

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Demian Brecht
On 2012-10-23, at 10:24 PM, David Hutto wrote: > count = 0 Don't use count. > for file_data in turn_text_to_txt: Use enumerate: for count, file_data in enumerate(turn_text_to_txt): > f = open('/home/david/files/%s_%s.txt' % (file_data.split(' ')[0], count), > 'w') Use with: with open('file

Re: Split single file into multiple files based on patterns

2012-10-23 Thread David Hutto
86 0.654000 > A1980KK18700010 50 130 3.199000 > A1980KK18700010 186 3366 4.78 > A1980KK18700010 30 186 1.285000 > A1980KK18700010 30 185 4.395000 > A1980KK18700010 185 186 9.00 > A1980KK18700010 25 30 3.493000 > > I want to split the file and get multiple files like A1980JE

Re: Split single file into multiple files based on patterns

2012-10-23 Thread satyam mukherjee
980KK18700010 25 30 3.493000 > > > > I want to split the file and get multiple files like A1980JE3937.txt > and A1980KK18700010.txt, where each file will contain column2, 3 and 4. > > Unless your source file is very large this should be sufficient: > > $ cat source &g

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Jason Friedman
; A1980KK18700010 30 186 1.285000 > A1980KK18700010 30 185 4.395000 > A1980KK18700010 185 186 9.00 > A1980KK18700010 25 30 3.493000 > > I want to split the file and get multiple files like A1980JE3937.txt and > A1980KK18700010.txt, where each file will contain column2, 3 and

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Jason Friedman
5 30 3.493000 > > I want to split the file and get multiple files like A1980JE3937.txt and > A1980KK18700010.txt, where each file will contain column2, 3 and 4. The sample data above shows the data grouped by file name. Will this be true generally? -- http://mail.python.org/mailman/listinfo/python-list

Split single file into multiple files based on patterns

2012-10-23 Thread satyam
185 4.395000 A1980KK18700010 185 186 9.00 A1980KK18700010 25 30 3.493000 I want to split the file and get multiple files like A1980JE3937.txt and A1980KK18700010.txt, where each file will contain column2, 3 and 4. Thanks Satyam -- http://mail.python.org/mailman/listinfo/python-list

Re: Opening multiple Files in Different Encoding

2012-07-11 Thread Steven D'Aprano
On Wed, 11 Jul 2012 11:15:02 -0700, subhabangalore wrote: > On Tuesday, July 10, 2012 11:16:08 PM UTC+5:30, Subhabrata wrote: >> Dear Group, >> >> I kept a good number of files in a folder. Now I want to read all of >> them. They are in different formats and different encoding. Using >> listdir/g

Re: Opening multiple Files in Different Encoding

2012-07-11 Thread Oscar Benjamin
On 11 July 2012 19:15, wrote: > On Tuesday, July 10, 2012 11:16:08 PM UTC+5:30, Subhabrata wrote: > > Dear Group, > > > > I kept a good number of files in a folder. Now I want to read all of > > them. They are in different formats and different encoding. Using > > listdir/glob.glob I am able to f

Re: Opening multiple Files in Different Encoding

2012-07-11 Thread subhabangalore
On Tuesday, July 10, 2012 11:16:08 PM UTC+5:30, Subhabrata wrote: > Dear Group, > > I kept a good number of files in a folder. Now I want to read all of > them. They are in different formats and different encoding. Using > listdir/glob.glob I am able to find the list but how to open/read or > proc

Re: Opening multiple Files in Different Encoding

2012-07-10 Thread Steven D'Aprano
On Tue, 10 Jul 2012 10:46:08 -0700, Subhabrata wrote: > Dear Group, > > I kept a good number of files in a folder. Now I want to read all of > them. They are in different formats and different encoding. Using > listdir/glob.glob I am able to find the list but how to open/read or > process them fo

Re: Opening multiple Files in Different Encoding

2012-07-10 Thread MRAB
On 10/07/2012 18:46, Subhabrata wrote: Dear Group, I kept a good number of files in a folder. Now I want to read all of them. They are in different formats and different encoding. Using listdir/glob.glob I am able to find the list but how to open/read or process them for different encodings? If

Opening multiple Files in Different Encoding

2012-07-10 Thread Subhabrata
Dear Group, I kept a good number of files in a folder. Now I want to read all of them. They are in different formats and different encoding. Using listdir/glob.glob I am able to find the list but how to open/read or process them for different encodings? If any one can help me out.I am using Pytho

Re: Distributing methods of a class across multiple files

2012-01-26 Thread Chris Angelico
On Fri, Jan 27, 2012 at 1:11 AM, Roy Smith wrote: > So, I'd say the driving principle should be that a function should do > one thing.  Every function should have an elevator talk.  You should be > able to get on an elevator with a function and when you ask it, "So, > what do you do?", it should b

Re: Distributing methods of a class across multiple files

2012-01-26 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > The old convention I'd learned was to keep functions down to a > (printer) page (classical 6 lines per inch, 11" high, tractor feed -- so > about 60 lines per function -- possibly extend to a second page if > really needed. The generalization of tha

Re: Distributing methods of a class across multiple files

2012-01-26 Thread Chris Angelico
On Thu, Jan 26, 2012 at 2:19 AM, lh wrote: > Third, length. Well 5000 lines eh... I'm nowhere near that guess I can > stick with one file. Of all the source files I have at work, the largest is about that, 5K lines. It gets a little annoying at times (rapid deployment requires GCC to do its magic

Re: Distributing methods of a class across multiple files

2012-01-25 Thread Neil Cerutti
On 2012-01-25, lh wrote: > First, thanks for all the thoughtful replies. I am grateful. > Second, I figured I'd get a lot of judgement about how I really > shouldn't be doing this. Should have pre-empted it :-) oh well. > There is a place IMHO for filename as another structuring > element to help

Re: Distributing methods of a class across multiple files

2012-01-25 Thread lh
First, thanks for all the thoughtful replies. I am grateful. Second, I figured I'd get a lot of judgement about how I really shouldn't be doing this. Should have pre-empted it :-) oh well. There is a place IMHO for filename as another structuring element to help humans in search. Also it can be con

Re: Distributing methods of a class across multiple files

2012-01-25 Thread Jean-Michel Pichavant
in test2.py). In short I would like to distribute code for one class across multiple files so a given file doesn't get ridiculously long. Thank you, Luke If the file is ridiculously long, could be that the class has a ridiculous number of methods. If you spread your class into multiple fil

Re: Distributing methods of a class across multiple files

2012-01-25 Thread Steven D'Aprano
) define a file test2.py which contains a set of methods that are > methods of class Foo defined in test.py. Technically, yes, this is possible, but you shouldn't need to do it. Needing to split a single class across multiple files is a sign of bad design. If the class is that huge, then it

Re: Distributing methods of a class across multiple files

2012-01-25 Thread Frank Millman
under the class but the class isn't textually in > test2.py). > > In short I would like to distribute code for one class across multiple > files so a given file doesn't get ridiculously long. > I take the point of the other responders that it is not a normal thing to d

Re: Distributing methods of a class across multiple files

2012-01-24 Thread Cameron Simpson
but the class isn't textually in | test2.py). | | In short I would like to distribute code for one class across multiple | files so a given file doesn't get ridiculously long. You may need to define "ridiculously long". What's your objecttion to a long file? What specific dif

Re: Distributing methods of a class across multiple files

2012-01-24 Thread Roy Smith
efined in test.py (normally I would just indent > them "def"'s under the class but the class isn't textually in > test2.py). > > In short I would like to distribute code for one class across multiple > files so a given file doesn't get ridiculously long. The stu

Distributing methods of a class across multiple files

2012-01-24 Thread lh
In short I would like to distribute code for one class across multiple files so a given file doesn't get ridiculously long. Thank you, Luke -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing multiple files with with-context

2011-05-23 Thread Ian Kelly
On Sun, May 22, 2011 at 8:48 PM, Shunichi Wakabayashi wrote: > One idea is using contextlib.nested(), > > from contextlib import nested > > with nested(*[open('list_%d.txt' % i, 'w') for i in range(LIST_LEN)]) as > fobjlist: >  for i in range(1000): >    fobjlist[random.randrange(LIST_LEN)].write

Writing multiple files with with-context

2011-05-22 Thread Shunichi Wakabayashi
To write onto multiple files on the same time (a number of files are variable), I'd like to code as follows, for example, IF I can do, LIST_LEN = 4 with [ open('list_%d.txt' % i, 'w') for i in range(LIST_LEN) ] as fobjlist: for i in range(1000): fobjlist[random.r

Re: with block for multiple files

2010-10-31 Thread Yingjie Lan
> Guido's time machine strikes again! It's already in Python > 3; your > example would be spelled: > > with open('scores.csv') as f, open('grades.csv', wt) as g: >     g.write(f.read()) > Indeed! Thanks, Chris and James. Yingjie -- http://mail.python.org/mailman/listinfo/python-list

Re: with block for multiple files

2010-10-31 Thread James Mills
On Mon, Nov 1, 2010 at 3:03 PM, Yingjie Lan wrote: > with open('scores.csv'), open('grades.csv', wt) as f,g: >     g.write(f.read()) One could write their own ContextManager here... cheers James -- -- James Mills -- -- "Problems are solved by method" -- http://mail.python.org/mailman/listinfo

Re: with block for multiple files

2010-10-31 Thread Chris Rebert
On Sun, Oct 31, 2010 at 10:03 PM, Yingjie Lan wrote: > Hi, > > Suppose I am working with two files simultaneously, > it might make sense to do this: > > with open('scores.csv'), open('grades.csv', wt) as f,g: >     g.write(f.read()) > > sure, you can do this with nested with-blocks, > but the one

with block for multiple files

2010-10-31 Thread Yingjie Lan
Hi, Suppose I am working with two files simultaneously, it might make sense to do this: with open('scores.csv'), open('grades.csv', wt) as f,g: g.write(f.read()) sure, you can do this with nested with-blocks, but the one above does not seem too complicated, it is like having a multiple as

Re: processing input from multiple files

2010-10-15 Thread John Posner
On 10/15/2010 6:59 AM, Christopher Steele wrote: Thanks, The issue with the times is now sorted, however I'm running into a problem towards the end of the script: File "sortoutsynop2.py", line 131, in newline = message_type+c+str(station_id)+c+newtime+c+lat+c+lon+c+c+"-"+c+ "002"

Re: processing input from multiple files

2010-10-15 Thread Christopher Steele
Thanks, The issue with the times is now sorted, however I'm running into a problem towards the end of the script: File "sortoutsynop2.py", line 131, in newline = message_type+c+str(station_id)+c+newtime+c+lat+c+lon+c+c+"-"+c+ "002" +c+"-"+c+"-"+c+str(pressure)+c TypeError: canno

Re: processing input from multiple files

2010-10-14 Thread John Posner
On 10/14/2010 10:44 AM, Christopher Steele wrote: The issue is that I need to be able to both, split the names of the files so that I can extract the relevant times, and open each individual file and process each line individually. Once I have achieved this I need to append the sorted files ont

Re: processing input from multiple files

2010-10-14 Thread John Posner
On 10/14/2010 6:08 AM, Christopher Steele wrote: Hi I've been trying to decode a series of observations from multiple files (each file is a different time) and put each type of observation into their own separate file. The script runs successfully for one file but whenever I try it for

Re: processing input from multiple files

2010-10-14 Thread Christopher Steele
cloud observations are going to follow - something that is not always reported at stations. I hope this has helped Chris On Thu, Oct 14, 2010 at 3:16 PM, John Posner wrote: > On 10/14/2010 6:08 AM, Christopher Steele wrote: > >> Hi >> >> I've been trying to decode a se

processing input from multiple files

2010-10-14 Thread Christopher Steele
Hi I've been trying to decode a series of observations from multiple files (each file is a different time) and put each type of observation into their own separate file. The script runs successfully for one file but whenever I try it for more they just overwrite each other. I'm new to

Re: reading multiple files

2010-09-09 Thread Mag Gam
Thanks for your response. I was going by this thread, http://mail.python.org/pipermail/tutor/2009-January/066101.html makes you wonder even if its possible. I will try your first solution by doing mkfifo on the files. On Thu, Sep 9, 2010 at 9:19 PM, Alain Ketterlin wrote: > Mag Gam writes:

Re: reading multiple files

2010-09-09 Thread Alain Ketterlin
Mag Gam writes: > I have 3 files which are constantly being updated therefore I use tail > -f /var/log/file1, tail -f /var/log/file2, and tail -f /var/log/file3 > > For 1 file I am able to manage by > tail -f /var/log/file1 | python prog.py > > prog.py looks like this: > f=sys.stdin > for line in

reading multiple files

2010-09-09 Thread Mag Gam
I have 3 files which are constantly being updated therefore I use tail -f /var/log/file1, tail -f /var/log/file2, and tail -f /var/log/file3 For 1 file I am able to manage by tail -f /var/log/file1 | python prog.py prog.py looks like this: f=sys.stdin for line in f: print line But how can I ge

Re: Split class across multiple files

2009-11-22 Thread Lie Ryan
eric.frederich wrote: I have a class which holds a connection to a server and a bunch of services. In this class I have methods that need to work with that connection and services. Right now there are about 50 methods some of which can be quite long. From an organizational standpoint, I'd like t

Re: Split class across multiple files

2009-11-20 Thread Terry Reedy
eric.frederich wrote: I have a class which holds a connection to a server and a bunch of services. In this class I have methods that need to work with that connection and services. Right now there are about 50 methods some of which can be quite long. From an organizational standpoint, I'd like

Re: Split class across multiple files

2009-11-20 Thread eric.frederich
Yeah... it does seem like a God Object. My reasoning for putting them all into one big class is that the class has references to all the required resources, connections, and services. The other option would be to have a simple object called Session which did nothing but login and hold those referen

Re: Split class across multiple files

2009-11-20 Thread Carl Banks
On Nov 20, 8:14 am, "eric.frederich" wrote: > I have a class which holds a connection to a server and a bunch of > services. > In this class I have methods that need to work with that connection > and services. > > Right now there are about 50 methods some of which can be quite long. > From an org

Re: Split class across multiple files

2009-11-20 Thread Diez B. Roggisch
eric.frederich schrieb: I have a class which holds a connection to a server and a bunch of services. In this class I have methods that need to work with that connection and services. Right now there are about 50 methods some of which can be quite long. From an organizational standpoint, I'd like

Split class across multiple files

2009-11-20 Thread eric.frederich
I have a class which holds a connection to a server and a bunch of services. In this class I have methods that need to work with that connection and services. Right now there are about 50 methods some of which can be quite long. >From an organizational standpoint, I'd like to have method implement

Re: Multiple files

2009-10-17 Thread Benjamin Kaplan
On Sat, Oct 17, 2009 at 9:58 PM, Someone Something wrote: > I was trying to write a program with just one class and it was working fine. > Then, I seperated that class into two different files and made the objects > and called the methods in a third (client.py IO.py main.py). Now, when I use > the

Multiple files

2009-10-17 Thread Someone Something
I was trying to write a program with just one class and it was working fine. Then, I seperated that class into two different files and made the objects and called the methods in a third (client.py IO.py main.py). Now, when I use the command: python client.py IO.py main.py Nothing prints. I think

Re: Tkinter, tkFileDialog - how to select multiple files ?

2009-04-07 Thread Steve Offutt
Hmm ... sorry folks - this works for me everywhere except on the machine I wrote it on ... Must be some sort of configuration problem... Steve -- http://mail.python.org/mailman/listinfo/python-list

Tkinter, tkFileDialog - how to select multiple files ?

2009-04-07 Thread Steve Offutt
Let me preface by saying that I don't do much Python, however, I am in my spare time, attempting to become somewhat comfortable with Python/ Tkinter. I just can't seem to understand what is the problem with this: -- import Tkinter, tkFileDialog root = Tkinter.Tk() files = tkFileDialog.askop

Posting multiple files via a web site.

2009-02-17 Thread pdl5000
I would like to start write a Python script that upload multiple files to a web server. I research the methods, and I am somewhat confused between using the http & urllib2 modules. I assume (and could be wrong) that the most basic method would be to use a cgi-Python script on the web server

Re: Break large file down into multiple files

2009-02-13 Thread Chris
On Feb 13, 1:19 pm, Chris wrote: > On Feb 13, 10:02 am, redbaron wrote: > > > > > > New to python I have a large file that I need to break up into > > > multiple smaller files. I need to break the large file into sections > > > where there are 65535 lines and then write those sections to sepe

Re: Break large file down into multiple files

2009-02-13 Thread Tim Chase
New to python I have a large file that I need to break up into multiple smaller files. I need to break the large file into sections where there are 65535 lines and then write those sections to seperate files. I am familiar with opening and writing files, however, I am struggling with creating

  1   2   >