Re: Text file with mixed end-of-line terminations

2011-09-01 Thread woooee
You can use f.read() to read the entire file's contents into a string, providing the file isn't huge. Then, split on "\r" and replace "\n" when found. A simple test: input_data = "abc\rdef\rghi\r\njkl\r\nmno\r\n" first_split = input_data.split("\r") for rec in first_split: rec = rec.replace("\

Re: Text file with mixed end-of-line terminations

2011-08-31 Thread Chris Rebert
On Wed, Aug 31, 2011 at 12:37 PM, Alex van der Spek wrote: > I have a text file that uses both '\r' and '\r\n' end-of-line terminations. > > The '\r' terminates the first 25 lines or so, the remainder is termiated > with '\r\n' > Is there a way to make it read one line at a time, regardless of th

Re: text file

2011-06-30 Thread John Gordon
In <15d8f853-7c87-427b-8f21-e8537bde8...@x12g2000yql.googlegroups.com> Siboniso Shangase writes: > i want to type this data in a text file it the same the diffrence is > the number that only increase and i canot write this up myself since > it up to 5000 samples > Data\ja1.wav Data\ja1.mfc > .

Re: text file

2011-06-30 Thread MRAB
On 01/07/2011 01:19, Siboniso Shangase wrote: Hi i m very new to python and i need hepl plz!! i want to type this data in a text file it the same the diffrence is the number that only increase and i canot write this up myself since it up to 5000 samples Data\ja1.wav Data\ja1.mfc Data\ja2.wav Da

Re: text file

2011-06-30 Thread Josh Benner
import os lst = [] for x in xrange(1, 5001): lst.append(r"Data\ma{0}.wav Data\ma{0}.mfc".format(x)) lst.insert(x-1, r"Data\ja{0}.wav Data\ja{0}.mfc".format(x)) with open("filename.txt", "w") as fd: sep = os.linesep fd.write(sep.join(lst)) On Thu, Jun 30, 2011 at 5:19 PM, Sibonis

Re: text file reformatting

2010-11-02 Thread iwawi
On Nov 1, 6:50 pm, "cbr...@cbrownsystems.com" wrote: > On Nov 1, 1:58 am, iwawi wrote: > > > > > > > On 1 marras, 09:59, "cbr...@cbrownsystems.com" > > > wrote: > > > On Oct 31, 11:46 pm, iwawi wrote: > > > > > On 31 loka, 21:48, Tim Chase wrote: > > > > > > > PRJ01001 4 00100END > > > > > > P

Re: text file reformatting

2010-11-01 Thread cbr...@cbrownsystems.com
On Nov 1, 1:58 am, iwawi wrote: > On 1 marras, 09:59, "cbr...@cbrownsystems.com" > > > > wrote: > > On Oct 31, 11:46 pm, iwawi wrote: > > > > On 31 loka, 21:48, Tim Chase wrote: > > > > > > PRJ01001 4 00100END > > > > > PRJ01002 3 00110END > > > > > > I would like to pick only some columns to a

Re: text file reformatting

2010-11-01 Thread iwawi
On 1 marras, 09:59, "cbr...@cbrownsystems.com" wrote: > On Oct 31, 11:46 pm, iwawi wrote: > > > > > > > On 31 loka, 21:48, Tim Chase wrote: > > > > > PRJ01001 4 00100END > > > > PRJ01002 3 00110END > > > > > I would like to pick only some columns to a new file and put them to a > > > > certain p

Re: text file reformatting

2010-11-01 Thread cbr...@cbrownsystems.com
On Oct 31, 11:46 pm, iwawi wrote: > On 31 loka, 21:48, Tim Chase wrote: > > > > > > PRJ01001 4 00100END > > > PRJ01002 3 00110END > > > > I would like to pick only some columns to a new file and put them to a > > > certain places (to match previous data) - definition file (def.csv) > > > could be

Re: text file reformatting

2010-10-31 Thread iwawi
On 31 loka, 21:48, Tim Chase wrote: > > PRJ01001 4 00100END > > PRJ01002 3 00110END > > > I would like to pick only some columns to a new file and put them to a > > certain places (to match previous data) - definition file (def.csv) > > could be something like this: > > > VARIABLE   FIELDSTARTS  

Re: text file reformatting

2010-10-31 Thread cbr...@cbrownsystems.com
On Oct 31, 12:48 pm, Tim Chase wrote: > > PRJ01001 4 00100END > > PRJ01002 3 00110END > > > I would like to pick only some columns to a new file and put them to a > > certain places (to match previous data) - definition file (def.csv) > > could be something like this: > > > VARIABLE   FIELDSTARTS

RE: text file reformatting

2010-10-31 Thread Braden Faulkner
Sorry to clarify, I was having issues getting this to work. I'm relatively new to Python. Sorry for the miscommunication. > Date: Sun, 31 Oct 2010 16:13:42 -0500 > From: python.l...@tim.thechases.com > To: brad...@hotmail.com > CC: python-list@python.org > Subject: Re: te

Re: text file reformatting

2010-10-31 Thread Tim Chase
On 10/31/10 14:52, Braden Faulkner wrote: import csv f = file('def.csv', 'rb') f.next() # discard the header row r = csv.reader(f, delimiter=';') fields = [ (varname, slice(int(start), int(start)+int(size)), width) for varname, start, size, width in r ]

RE: text file reformatting

2010-10-31 Thread Braden Faulkner
I also am having issues with this. > Date: Sun, 31 Oct 2010 14:48:09 -0500 > From: python.l...@tim.thechases.com > To: iwawi...@gmail.com > Subject: Re: text file reformatting > CC: python-list@python.org > > > PRJ01001 4 00100END > > PRJ01002 3 00110END > >

Re: text file reformatting

2010-10-31 Thread Tim Chase
PRJ01001 4 00100END PRJ01002 3 00110END I would like to pick only some columns to a new file and put them to a certain places (to match previous data) - definition file (def.csv) could be something like this: VARIABLEFIELDSTARTS FIELD SIZE NEW PLACE IN NEW DATA FILE ProjID ;

Re: Text file to XML representation

2009-10-22 Thread Jorgen Grahn
On Wed, 2009-10-21, kak...@gmail.com wrote: > Hello, > I would like to make a program that takes a text file with the > following representation: > > outlook = sunny > | humidity <= 70: yes (2.0) > | humidity > 70: no (3.0) > outlook = overcast: yes (4.0) > outlook = rainy > | windy = TRUE: n

Re: Text file to XML representation

2009-10-21 Thread Bruno Desthuilliers
kak...@gmail.com a écrit : Hello, I would like to make a program that takes a text file with the following representation: outlook = sunny | humidity <= 70: yes (2.0) | humidity > 70: no (3.0) outlook = overcast: yes (4.0) outlook = rainy | windy = TRUE: no (2.0) | windy = FALSE: yes (3.

Re: text file

2008-10-01 Thread Tim Golden
[EMAIL PROTECTED] wrote: HI all, i have some problem with the code belove, i have a list of servers in a textfile (elencopc.txt) i would to retrieve informations via WMI ( cicle for ), but i don't understand if the code is correct: Try this, using http://timgolden.me.uk/python/wmi.html :

Re: text file

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 07:19:44 -0700, yqyq22 wrote: > My problem is how to translate this vbs in python: > > Dim fso > Dim strComputer > Set fso = CreateObject("Scripting.FileSystemObject") Set ElencoPC = > fso.OpenTextFile("elencoPC.txt" , 1, False) Do Until > ElencoPC.AtEndOfStream > strComputer =

Re: text file

2008-10-01 Thread yqyq22
On Oct 1, 4:03 pm, [EMAIL PROTECTED] wrote: > HI all, > i have some problem with the code belove, i have a list of servers in > a textfile (elencopc.txt) i would to retrieve informations via WMI > ( cicle for ), but i don't understand if the code is correct: > > import win32com.client > import

Re: text file vs. cPickle vs sqlite a design question

2007-04-11 Thread Bruno Desthuilliers
Dag a écrit : > I have an application which works with lists of tuples of the form > (id_nr,'text','more text',1 or 0). I'll have maybe 20-50 or so of these > lists containing anywhere from 3 to over 3 tuples. The actions I > need to do is either append a new tuple to the end of the list, di

Re: text file vs. cPickle vs sqlite a design question

2007-04-11 Thread Paddy
On Apr 11, 5:40 pm, Dag <[EMAIL PROTECTED]> wrote: > I have an application which works with lists of tuples of the form > (id_nr,'text','more text',1 or 0). I'll have maybe 20-50 or so of these > lists containing anywhere from 3 to over 3 tuples. The actions I > need to do is either append a

Re: text file vs. cPickle vs sqlite a design question

2007-04-11 Thread Bruno Desthuilliers
John Machin a écrit : (snip) > ... and a few more cents: > > There are *two* relations/tables involved (at least): a "tuple" table > and a "list" table. Mmm... From a purely technical POV, not necessarily. If there's no need for anything else than distinguishing between different lists, a singl

Re: text file vs. cPickle vs sqlite a design question

2007-04-11 Thread John Machin
On Apr 12, 7:09 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Dag a écrit : > > > > > I have an application which works with lists of tuples of the form > > (id_nr,'text','more text',1 or 0). I'll have maybe 20-50 or so of these > > lists containing anywhere from 3 to over 3 tuples. Th

Re: text file vs. cPickle vs sqlite a design question

2007-04-11 Thread Bruno Desthuilliers
Dag a écrit : > I have an application which works with lists of tuples of the form > (id_nr,'text','more text',1 or 0). I'll have maybe 20-50 or so of these > lists containing anywhere from 3 to over 3 tuples. The actions I > need to do is either append a new tuple to the end of the list, di

Re: text file vs. cPickle vs sqlite a design question

2007-04-11 Thread Gabriel Genellina
En Wed, 11 Apr 2007 13:40:02 -0300, Dag <[EMAIL PROTECTED]> escribió: > I have an application which works with lists of tuples of the form > (id_nr,'text','more text',1 or 0). I'll have maybe 20-50 or so of these > lists containing anywhere from 3 to over 3 tuples. The actions I > need to do

Re: text file parsing (awk -> python)

2006-11-22 Thread bearophileHUGS
Peter Otten, your solution is very nice, it uses groupby splitting on empty lines, so it doesn't need to read the whole files into memory. But Daniel Nogradi says: > But the names of the fields (node, x, y) keeps changing from file to > file, even their number is not fixed, sometimes it is (node,

Re: text file parsing (awk -> python)

2006-11-22 Thread Daniel Nogradi
> > I have an awk program that parses a text file which I would like to > > rewrite in python. The text file has multi-line records separated by > > empty lines and each single-line field has two subfields: > > > > node 10 > > x -1 > > y 1 > > > > node 11 > > x -2 > > y 1 > > > > node 12 > > x -3 >

Re: text file parsing (awk -> python)

2006-11-22 Thread Peter Otten
Daniel Nogradi wrote: > I have an awk program that parses a text file which I would like to > rewrite in python. The text file has multi-line records separated by > empty lines and each single-line field has two subfields: > > node 10 > x -1 > y 1 > > node 11 > x -2 > y 1 > > node 12 > x -3 > y