Re: Reading files from .ar / .deb archives

2015-11-24 Thread Ben Finney
Кисик Мурысик writes: > Hello! > I'm new to Python, so I decided to learn it Congratulations! Python is a fine language to learn, and this is the place to discuss general Python topics. You may also want to join the ‘tutor’ forum https://mail.python.org/mailman/listinfo/tutor>, which is specifi

Re: Reading files in from the proper directory

2012-02-09 Thread Peter Otten
smac2...@comcast.net wrote: > On Feb 7, 3:16 pm, Peter Otten <__pete...@web.de> wrote: >> smac2...@comcast.net wrote: >> > xls_files = glob.glob(in_dir + "*.xls") >> >> Try changing that to >> >> pattern = os.path.join(in_dir, "*.xls") >> xls_files = glob.glob(pattern) >> >> os.path.join() inser

Re: Reading files in from the proper directory

2012-02-09 Thread SMac2347
On Feb 7, 3:16 pm, Peter Otten <__pete...@web.de> wrote: > smac2...@comcast.net wrote: > > xls_files   = glob.glob(in_dir + "*.xls") > > Try changing that to > > pattern = os.path.join(in_dir, "*.xls") > xls_files = glob.glob(pattern) > > os.path.join() inserts a (back)slash between directory and f

Re: Reading files in from the proper directory

2012-02-09 Thread SMac2347
On Feb 7, 3:16 pm, Peter Otten <__pete...@web.de> wrote: > smac2...@comcast.net wrote: > > xls_files   = glob.glob(in_dir + "*.xls") > > Try changing that to > > pattern = os.path.join(in_dir, "*.xls") > xls_files = glob.glob(pattern) > > os.path.join() inserts a (back)slash between directory and f

Re: Reading files in from the proper directory

2012-02-07 Thread Peter Otten
smac2...@comcast.net wrote: > xls_files = glob.glob(in_dir + "*.xls") Try changing that to pattern = os.path.join(in_dir, "*.xls") xls_files = glob.glob(pattern) os.path.join() inserts a (back)slash between directory and filename if necessary. > merge_xls(in_dir="C:\Documents and Settings\

Re: Reading files in from the proper directory

2012-02-07 Thread John Gordon
In <9bfb3e39-2bc6-4399-90cc-1c53aa062...@h6g2000yqk.googlegroups.com> smac2...@comcast.net writes: > xls_files = glob.glob(in_dir + "*.xls") You may want to put a directory separator character in between the directory name and the filename glob pattern. -- John Gordon A

Re: Reading files in from the proper directory

2012-02-07 Thread John Gordon
In smac2...@comcast.net writes: > Am I correct in thinking that I need to change the current working > directory to this folder in order for Python to read in these files, > then generate my output? You don't have to do it that way, no. In general, when opening a file, you can do it two ways:

Re: Reading files in from the proper directory

2012-02-07 Thread SMac2347
On Feb 7, 1:40 pm, Dave Angel wrote: > On 02/07/2012 01:14 PM, smac2...@comcast.net wrote:> Hello. I am admittedly a > Python novice, and ran into some trouble > > trying to write a program that will pull multiple excel files all into > > one file, with each file on a different sheet. > > > I am

Re: Reading files in from the proper directory

2012-02-07 Thread SMac2347
Thanks for the responses. Below is the code I have thus far. while the program runs glitch-free, it only results in the printing of the message: "NOTE *** No xls files in C:/Documents and Settings/smacdon/." as specified by my code. Any idea as to why it might be unable to find the .xls documents

Re: Reading files in from the proper directory

2012-02-07 Thread Peter Otten
smac2...@comcast.net wrote: > Hello. I am admittedly a Python novice, and ran into some trouble > trying to write a program that will pull multiple excel files all into > one file, with each file on a different sheet. > > I am confident most of the code is correct, as the program runs > without a

Re: Reading files in from the proper directory

2012-02-07 Thread Dave Angel
On 02/07/2012 01:14 PM, smac2...@comcast.net wrote: Hello. I am admittedly a Python novice, and ran into some trouble trying to write a program that will pull multiple excel files all into one file, with each file on a different sheet. I am confident most of the code is correct, as the program r

Re: Reading files, splitting on a delimiter and newlines.

2007-07-26 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On Jul 25, 8:46 am, [EMAIL PROTECTED] wrote: > >>Hello, >> >>I have a situation where I have a file that contains text similar to: >> >>myValue1 = contents of value1 >>myValue2 = contents of value2 but >>with a new line here >>myValue3 = conten

Re: Reading files, splitting on a delimiter and newlines.

2007-07-26 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hello, > > I have a situation where I have a file that contains text similar to: > > myValue1 = contents of value1 > myValue2 = contents of value2 but > with a new line here > myValue3 = contents of value3 > > My first approach was to open th

Re: Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread Hendrik van Rooyen
: <[EMAIL PROTECTED]> Wrote: > On Jul 25, 10:46 am, [EMAIL PROTECTED] wrote: > > Hello, > > > > I have a situation where I have a file that contains text similar to: > > > > myValue1 = contents of value1 > > myValue2 = contents of value2 but > > with a new line here > > myV

Re: Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread chrispwd
On Jul 25, 7:56 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jul 25, 8:46 am, [EMAIL PROTECTED] wrote: > > > > > Hello, > > > I have a situation where I have a file that contains text similar to: > > > myValue1 = contents of value1 > > myValue2 = contents of value2 but > >

Re: Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 25, 8:46 am, [EMAIL PROTECTED] wrote: > Hello, > > I have a situation where I have a file that contains text similar to: > > myValue1 = contents of value1 > myValue2 = contents of value2 but > with a new line here > myValue3 = contents of value3 > > My first approach

Re: Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread John Machin
On Jul 26, 3:08 am, Stargaming <[EMAIL PROTECTED]> wrote: > On Wed, 25 Jul 2007 09:16:26 -0700, kyosohma wrote: > > On Jul 25, 10:46 am, [EMAIL PROTECTED] wrote: > >> Hello, > > >> I have a situation where I have a file that contains text similar to: > > >> myValue1 = contents of value1 > >> myValu

Re: Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread Stargaming
On Wed, 25 Jul 2007 09:16:26 -0700, kyosohma wrote: > On Jul 25, 10:46 am, [EMAIL PROTECTED] wrote: >> Hello, >> >> I have a situation where I have a file that contains text similar to: >> >> myValue1 = contents of value1 >> myValue2 = contents of value2 but >> with a new l

Re: Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread kyosohma
On Jul 25, 10:46 am, [EMAIL PROTECTED] wrote: > Hello, > > I have a situation where I have a file that contains text similar to: > > myValue1 = contents of value1 > myValue2 = contents of value2 but > with a new line here > myValue3 = contents of value3 > > My first approach

Re: reading files in small chunks?

2006-04-14 Thread Rajesh Sathyamoorthy
Hi,What chunk sizes do you normally use in your code?Thank You.On 4/14/06, Amit Khemka <[EMAIL PROTECTED] > wrote:On 4/14/06, Rajesh Sathyamoorthy < [EMAIL PROTECTED]> wrote:> Hi,>> I wanted to know why it is more efficient to read a file in smaller chunks (> using file() or open() )? If this is no

Re: reading files in small chunks?

2006-04-14 Thread Amit Khemka
On 4/14/06, Rajesh Sathyamoorthy <[EMAIL PROTECTED]> wrote: > Hi, > > I wanted to know why it is more efficient to read a file in smaller chunks ( > using file() or open() )? If this is not done, will this lead to errors in > the data read or just results in slower performance? > > Thank You. It

Re: reading files in small chunks?

2006-04-14 Thread Rajesh Sathyamoorthy
Hi,Could I have some links? It would be very helpful.Thank You.On 4/14/06, Felipe Almeida Lessa wrote: Em Sex, 2006-04-14 às 13:45 +0800, Rajesh Sathyamoorthy escreveu:> I wanted to know why it is more efficient to read a file in smaller> chunks ( using file() or open() )?It's more efficient in som

Re: reading files in small chunks?

2006-04-13 Thread Felipe Almeida Lessa
Em Sex, 2006-04-14 às 13:45 +0800, Rajesh Sathyamoorthy escreveu: > I wanted to know why it is more efficient to read a file in smaller > chunks ( using file() or open() )? It's more efficient in some cases, and worse on others. It also depends on how you implement the read loop. I won't elaborate

Re: reading files into dicts

2006-01-01 Thread Alex Martelli
rbt <[EMAIL PROTECTED]> wrote: ... > Thanks to everyone for the tips on eval and repr. I went with the > cPickle suggestion... this is awesome! It was the easiest and quickest > solution performance-wise. Just makes me think, "Wow... how the heck > does pickle do that?!" pickle.py implements

Re: reading files into dicts

2005-12-30 Thread Tim Williams (gmail)
On 30/12/05, Chris F.A. Johnson <[EMAIL PROTECTED]> wrote: On 2005-12-30, Tim Williams (gmail) wrote:> Apologies for the top post, it was my first attempt at using gmail's> pda-enabled web interface. There is no option to bottom post.Can you not move the cursor? Nope,  there is a checkbox opti

Re: reading files into dicts

2005-12-30 Thread Fuzzyman
ConfigObj is good - it (effectively) turns a dictionary into an ini file, and vice versa. There is also built in support for type conversion. See http://www.voidspace.org.uk/python/configobj.html See the ConfigPersist module which has functions to use ConfigObj for data persistence. It explains

Re: reading files into dicts

2005-12-29 Thread Chris F.A. Johnson
On 2005-12-30, Tim Williams (gmail) wrote: > Apologies for the top post, it was my first attempt at using gmail's > pda-enabled web interface. There is no option to bottom post. Can you not move the cursor? -- Chris F.A. Johnson, author | Shell Scriptin

Re: reading files into dicts

2005-12-29 Thread rbt
Gary Herron wrote: > rbt wrote: > >> What's a good way to write a dictionary out to a file so that it can >> be easily read back into a dict later? I've used realines() to read >> text files into lists... how can I do the same thing with dicts? >> Here's some sample output that I'd like to writ

Re: reading files into dicts

2005-12-29 Thread Tim Williams (gmail)
Apologies for the top post, it was my first attempt at using gmail's pda-enabled web interface. There is no option to bottom post. Apart from the mistake in my previous reply, when I meant to suggest using import instead of eval() not repr(). I also omitted an example. So here goes -but I don't kn

Re: reading files into dicts

2005-12-29 Thread Tim Williams (gmail)
A further thought, if you write the data to a file in the correct format, you can use import and reload to access the data later instead of repr. On 12/29/05, Tim Williams (gmail) <[EMAIL PROTECTED]> wrote: > On 30/12/05, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > > > > > > >>> d = {'.\\sync_p

Re: reading files into dicts

2005-12-29 Thread Gary Herron
rbt wrote: >What's a good way to write a dictionary out to a file so that it can be >easily read back into a dict later? I've used realines() to read text >files into lists... how can I do the same thing with dicts? Here's some >sample output that I'd like to write to file and then read back in

Re: reading files into dicts

2005-12-29 Thread limodou
2005/12/30, rbt <[EMAIL PROTECTED]>: > What's a good way to write a dictionary out to a file so that it can be > easily read back into a dict later? I've used realines() to read text > files into lists... how can I do the same thing with dicts? Here's some > sample output that I'd like to write to

Re: reading files into dicts

2005-12-29 Thread Tim Williams (gmail)
On 30/12/05, Giovanni Bajo <[EMAIL PROTECTED]> wrote: >>> d = {'.\\sync_pics.py': 1135900993, '.\\file_history.txt': 1135900994, '.\\New Text Document.txt': 1135900552}>>> file("foo", "w").write(repr(d))>>> data = "" >>> data"{'.sync_pics.py': 1135900993, '.file_history.txt': 1135900994

Re: reading files into dicts

2005-12-29 Thread Giovanni Bajo
rbt wrote: > What's a good way to write a dictionary out to a file so that it can > be easily read back into a dict later? I've used realines() to read > text > files into lists... how can I do the same thing with dicts? Here's > some sample output that I'd like to write to file and then read back

Re: reading files into dicts

2005-12-29 Thread Tim Williams (gmail)
On 30/12/05, rbt <[EMAIL PROTECTED]> wrote: What's a good way to write a dictionary out to a file so that it can beeasily read back into a dict later? I've used realines() to read textfiles into lists... how can I do the same thing with dicts? Here's some sample output that I'd like to write to fil

Re: reading files

2005-12-20 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Mike Meyer wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> The text you read is still hanging around, waiting for you to use it. Once >> you are done with it, you might want to reclaim that memory used, >> especially if it is a 100MB text file: >> >> mytext = "" #

Re: reading files

2005-12-19 Thread Mike Meyer
Steven D'Aprano <[EMAIL PROTECTED]> writes: > The text you read is still hanging around, waiting for you to use it. Once > you are done with it, you might want to reclaim that memory used, > especially if it is a 100MB text file: > > mytext = "" # re-bind the name 'mytext' to the empty string If

Re: reading files

2005-12-19 Thread Fuzzyman
Steven D'Aprano wrote: [snip..] > (It is good practice to close the file as soon as you can, especially on > platforms like Windows where open files can't be read by any other process.) > Unfortuantely not the case - on windoze (XP SP2 at least) you can open a file in one process (for reading or w

Re: reading files

2005-12-19 Thread Steven D'Aprano
On Mon, 19 Dec 2005 02:47:22 -0800, Johhny wrote: > Thanks for your assistance, Is it proper practice in python to flush > any memory when you exit? for example Ive read the file into memory, > when I close the file do I also have to flush any memory allocations ? You've done this: fileobject =

Re: reading files

2005-12-19 Thread bonono
Johhny wrote: > Thanks for your assistance, Is it proper practice in python to flush > any memory when you exit? for example Ive read the file into memory, > when I close the file do I also have to flush any memory allocations ? No. you don't need to and shouldn't unless you have very very specifi

Re: reading files

2005-12-19 Thread Johhny
Thanks for your assistance, Is it proper practice in python to flush any memory when you exit? for example Ive read the file into memory, when I close the file do I also have to flush any memory allocations ? -- http://mail.python.org/mailman/listinfo/python-list

Re: reading files

2005-12-19 Thread bonono
Steve Holden wrote: > Johhny wrote: > > Hello All, > > > > I am working my way through learning python as a language. I am having > > some issues with something that looks right and does not work. I am > > trying to get myself more familure with reading files. Based on the > > tutorials at www.pyt

Re: reading files

2005-12-19 Thread Jorge Godoy
"Johhny" <[EMAIL PROTECTED]> writes: > ===SNIP=== > import string Why's that here? You don't need that import... > vsftpd=open('vsftpd.conf', 'r') Open the file and associate its resulting *object* to the 'vsftpd' variable. > print vsftpd Print the object's __str__. > vsftpd.read() Read t

Re: reading files

2005-12-19 Thread Steve Holden
Johhny wrote: > Hello All, > > I am working my way through learning python as a language. I am having > some issues with something that looks right and does not work. I am > trying to get myself more familure with reading files. Based on the > tutorials at www.python.org This "should" work. but im

Re: reading files

2005-12-19 Thread bonono
Johhny wrote: > Hello All, > > I am working my way through learning python as a language. I am having > some issues with something that looks right and does not work. I am > trying to get myself more familure with reading files. Based on the > tutorials at www.python.org This "should" work. but im

Re: reading files with error

2005-09-18 Thread jepler
On Sun, Sep 18, 2005 at 02:15:00PM +1000, Maurice Ling wrote: > Sorry but what are SEEK_END and SEEK_SET? Oops, that's what I get for snipping a part of a larger program. SEEK_SET = 0 SEEK_END = 2 Jeff pgpC1OTox5VvO.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/pyt

Re: reading files with error

2005-09-17 Thread Christian Stapfer
Maurice Ling <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [EMAIL PROTECTED] wrote: > >>I have written a program to do something similar. My strategy is: >> * use os.read() to read 512 bytes at a time >> * when os.read fails, seek to the next multiple of 512 bytes >> and write '

Re: reading files with error

2005-09-17 Thread Maurice Ling
[EMAIL PROTECTED] wrote: I have written a program to do something similar. My strategy is: * use os.read() to read 512 bytes at a time * when os.read fails, seek to the next multiple of 512 bytes and write '\0' * 512 to the output I notice this code doesn't deal properly with short reads, but

Re: reading files with error

2005-09-17 Thread jepler
I have written a program to do something similar. My strategy is: * use os.read() to read 512 bytes at a time * when os.read fails, seek to the next multiple of 512 bytes and write '\0' * 512 to the output I notice this code doesn't deal properly with short reads, but in my experience they ne

Re: Reading files in /var/spool/rwho/whod.*

2005-06-30 Thread Fredrik Normann
Dennis Lee Bieber wrote: > On Mon, 27 Jun 2005 13:26:12 +0200, Fredrik Normann <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > >>Hello, >> >>I'm trying to read the binary files under /var/spool/rwho/ so I'm wondering >>if >>anyone has done that before or could give me som

Re: Reading files in /var/spool/rwho/whod.*

2005-06-28 Thread Fredrik Normann
Fredrik Normann wrote: > Hello, > > I'm trying to read the binary files under /var/spool/rwho/ so I'm > wondering if anyone has done that before or could give me some clues on > how to read those files. I've tried to use the binascii module without > any luck. A friend of mine made this C-prog

RE: Reading files into a 2D list.

2005-05-11 Thread Oyvind Ostlund
guages and libs like DirectX lately. Thanks ØØ -Original Message- From: Larry Bates [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 11, 2005 3:55 PM To: Oyvind Ostlund Cc: python-list@python.org Subject: Re: Reading files into a 2D list. Few observations. 1) Don't concatenate pa

Re: Reading files into a 2D list.

2005-05-11 Thread Larry Bates
Few observations. 1) Don't concatenate pathnames yourself use os.path.join, that makes your code portable. lexi_file = open(os.path.join(sys.path[0],"lexi",files), "r") 2) Start with an empty list and append your "lines" lists: files_and_lines=[] filenumber = 0 for files in file_names: fpa

RE: Reading files into a 2D list.

2005-05-11 Thread Oyvind Ostlund
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Klaus Alexander Seistrup Sent: Wednesday, May 11, 2005 12:14 PM To: python-list@python.org Subject: Re: Reading files into a 2D list. Øyvind Østlund wrote: > I have a list of about 20 files that I w

Re: Reading files into a 2D list.

2005-05-11 Thread Klaus Alexander Seistrup
Øyvind Østlund wrote: > I have a list of about 20 files that I want to read line by > line into a 2D list. So the first dimension will be each file, > and the second every line in that file. > > I tried to do something like this: > > files_and_lines = [][] > filenumber = 0 > > for