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

Reading files from .ar / .deb archives

2015-11-24 Thread Кисик Мурысик
Hello! I'm new to Python, so I decided to learn it and write simple apt alternative (apt is somewhat broken for me). But I can't decide - can I read just one file (/DEBIAN/control) from archive without unpacking it, or do I need to unpack? And what module I can use to handle .ar files? (I read i

Re: Problem while reading files from hdfs using python

2015-02-03 Thread Dave Angel
On 01/25/2015 03:23 PM, Shalini Ravishankar wrote: Hello Everyone, I am trying to read(open) and write files in hdfs inside a python script. But having error. Please copy/paste the full error traceback. Can someone tell me what is wrong here. Code (full): sample.py #!/usr/bin/python

Problem while reading files from hdfs using python

2015-01-25 Thread Shalini Ravishankar
Hello Everyone, I am trying to read(open) and write files in hdfs inside a python script. But having error. Can someone tell me what is wrong here. Code (full): sample.py #!/usr/bin/python from subprocess import Popen, PIPE print "Before Loop" cat = Popen(["h

Re: Pyro4 - reading files

2014-01-29 Thread Jean-Michel Pichavant
- Original Message - > Hello there. > > I am currently working on a project involving the use of Pyro4. > > I have a scenario. > > We have the pc named A, and a pc named B. > > On pc B lies a python script, that includes pyro, and a method for > reading

Pyro4 - reading files

2014-01-28 Thread ganea . ionut . iulian
Hello there. I am currently working on a project involving the use of Pyro4. I have a scenario. We have the pc named A, and a pc named B. On pc B lies a python script, that includes pyro, and a method for reading files. On pc A, we create an instance to the pyro object on pc B. And we call

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

Reading files in from the proper directory

2012-02-07 Thread SMac2347
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 any errors and I found the base of it onli

Re: Question about Reading Files

2010-09-05 Thread genxtech
On Sep 5, 4:16 am, Peter Otten <__pete...@web.de> wrote: > genxtech wrote: > > Hello.  I am still really new to python and I have a project where I > > am trying to use the data files from another program and write a new > > program with new user interface and all.  My first step was to open > > on

Re: Question about Reading Files

2010-09-05 Thread Mats Rauhala
On 2010-09-05, genxtech wrote: > I am using Fedora 13. When I run the file command the response is > that it is a 'data' file. If there are any tips on how to > programatically figure out the format, I would greatly appreciate it. I tried python-magic from the fedora repositories, but was unabl

Re: Question about Reading Files

2010-09-05 Thread Peter Otten
genxtech wrote: > Hello. I am still really new to python and I have a project where I > am trying to use the data files from another program and write a new > program with new user interface and all. My first step was to open > one of the files in 'rb' mode and print the contents, but I am > unf

Re: Question about Reading Files

2010-09-04 Thread genxtech
On Sep 4, 7:23 pm, Mats Rauhala wrote: > On 2010-09-04, genxtech wrote: > > > Hello.  I am still really new to python and I have a project where I > > am trying to use the data files from another program and write a new > > program with new user interface and all.  My first step was to open > > o

Re: Question about Reading Files

2010-09-04 Thread MRAB
On 05/09/2010 00:04, genxtech wrote: Hello. I am still really new to python and I have a project where I am trying to use the data files from another program and write a new program with new user interface and all. My first step was to open one of the files in 'rb' mode and print the contents,

Re: Question about Reading Files

2010-09-04 Thread Mats Rauhala
On 2010-09-04, genxtech wrote: > Hello. I am still really new to python and I have a project where I > am trying to use the data files from another program and write a new > program with new user interface and all. My first step was to open > one of the files in 'rb' mode and print the contents,

Re: Question about Reading Files

2010-09-04 Thread genxtech
I forgot to mention that the output was the first 100 bytes of the output -- http://mail.python.org/mailman/listinfo/python-list

Question about Reading Files

2010-09-04 Thread genxtech
Hello. I am still really new to python and I have a project where I am trying to use the data files from another program and write a new program with new user interface and all. My first step was to open one of the files in 'rb' mode and print the contents, but I am unfamiliar with the format. H

Re: speeding up reading files (possibly with cython)

2009-03-09 Thread S Arrowsmith
Carl Banks wrote: >When building a very large structure like you're doing, the cyclic >garbage collector can be a bottleneck. Try disabling the cyclic >garbage collector before building the large dictionary, and re- >enabling it afterwards. > >import gc >gc.disable() >try: >for line in file:

Re: speeding up reading files (possibly with cython)

2009-03-08 Thread Tim Chase
Steven D'Aprano wrote: per wrote: currently, this is very slow in python, even if all i do is break up each line using split() ** and store its values in a dictionary, ** indexing by one of the tab separated values in the file. If that's the problem, the sol

Re: speeding up reading files (possibly with cython)

2009-03-08 Thread Timothy N. Tsvetkov
> > If that's the problem, the solution is: get more memory. > Or maybe think about algorithm, which needs less memory... My experience tells me, that each time when you want to store a lot of data into dict (or other structure) to analyze it then, you can find a way not to store so much amount of

Re: speeding up reading files (possibly with cython)

2009-03-08 Thread Carl Banks
On Mar 7, 3:06 pm, per wrote: > hi all, > > i have a program that essentially loops through a textfile file thats > about 800 MB in size containing tab separated data... my program > parses this file and stores its fields in a dictionary of lists. When building a very large structure like you're

Re: speeding up reading files (possibly with cython)

2009-03-08 Thread Peter Otten
per wrote: > i have a program that essentially loops through a textfile file thats > about 800 MB in size containing tab separated data... my program > parses this file and stores its fields in a dictionary of lists. > > for line in file: > split_values = line.strip().split('\t') > # do stuff

Re: speeding up reading files (possibly with cython)

2009-03-07 Thread Steven D'Aprano
per wrote: > hi all, > > i have a program that essentially loops through a textfile file thats > about 800 MB in size containing tab separated data... my program > parses this file and stores its fields in a dictionary of lists. > > for line in file: > split_values = line.strip().split('\t') >

Re: speeding up reading files (possibly with cython)

2009-03-07 Thread John Machin
On Mar 8, 9:06 am, per wrote: > hi all, > > i have a program that essentially loops through a textfile file thats > about 800 MB in size containing tab separated data... my program > parses this file and stores its fields in a dictionary of lists. > > for line in file: >   split_values = line.stri

Re: speeding up reading files (possibly with cython)

2009-03-07 Thread John Machin
On Mar 8, 9:06 am, per wrote: > hi all, > > i have a program that essentially loops through a textfile file thats > about 800 MB in size containing tab separated data... my program > parses this file and stores its fields in a dictionary of lists. > > for line in file: >   split_values = line.stri

Re: speeding up reading files (possibly with cython)

2009-03-07 Thread Tim Chase
i have a program that essentially loops through a textfile file thats about 800 MB in size containing tab separated data... my program parses this file and stores its fields in a dictionary of lists. for line in file: split_values = line.strip().split('\t') # do stuff with split_values curre

Re: speeding up reading files (possibly with cython)

2009-03-07 Thread skip
me> reader = csv.reader(open(fname, "rb")) me> for row in reader: me> ... duh... How about reader = csv.reader(open(fname, "rb"), delimiter='\t') for row in reader: ... S -- http://mail.python.org/mailman/listinfo/python-list

Re: speeding up reading files (possibly with cython)

2009-03-07 Thread skip
>> about 800 MB in size containing tab separated data... my program >> parses this file and stores its fields in a dictionary of lists. ... >> currently, this is very slow in python, even if all i do is break up >> each line using split() and store its values in a dictionary,

speeding up reading files (possibly with cython)

2009-03-07 Thread per
hi all, i have a program that essentially loops through a textfile file thats about 800 MB in size containing tab separated data... my program parses this file and stores its fields in a dictionary of lists. for line in file: split_values = line.strip().split('\t') # do stuff with split_value

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

Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread chrispwd
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 the file, use readlines to split the lines on the

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

reading files in small chunks?

2006-04-13 Thread Rajesh Sathyamoorthy
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. -- http://mail.python.org/mailman/listinfo/python-list

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

reading files into dicts

2005-12-29 Thread rbt
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 into a dict: {'.\

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 fil

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

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

reading files

2005-12-19 Thread Johhny
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 not sure what

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

reading files with error

2005-09-17 Thread Maurice LING
Hi, I'm trying to read some files (video files) that seems to have some errors in it. Basically, I cannot copy it out of discs as that gives me an error message but I can still play the file using a media player like VLC or QuickTime. I understand that copying a file will also invoke checking

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

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

2005-06-27 Thread Fredrik Normann
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. Best regards, -fredrik-normann- -- http://mail.python.org/mailman/li

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

Reading files into a 2D list.

2005-05-11 Thread Oyvind Ostlund
I am not sure what the right syntax is here. So please help me out (started 2 days ago). 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: f