How to streamingly read text file and display whenever updated text

2013-10-05 Thread galeomaga
#!/usr/bin/python import time f = open('/home/martin/Downloads/a.txt') while 1: for line in f: print line; time.sleep(1); -- https://mail.python.org/mailman/listinfo/python-list

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 12:44 PM, Joshua Landau wrote: > On 6 August 2013 11:52, Chris Angelico wrote: >> On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson >> wrote: >>> with open('/home/collier/pytest/sort.TXT') as file: >>> sorted(file, key=str.casefold, reverse=True) >>> >>> >

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Devyn Collier Johnson
On 08/06/2013 06:52 AM, Chris Angelico wrote: On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson wrote: with open('/home/collier/pytest/sort.TXT') as file: sorted(file, key=str.casefold, reverse=True) Thanks for the advice Joshua. I find these tips very useful. However, how

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Joshua Landau
On 6 August 2013 11:52, Chris Angelico wrote: > On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson > wrote: >> with open('/home/collier/pytest/sort.TXT') as file: >> sorted(file, key=str.casefold, reverse=True) >> >> >> Thanks for the advice Joshua. I find these tips very useful.

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson wrote: > with open('/home/collier/pytest/sort.TXT') as file: > sorted(file, key=str.casefold, reverse=True) > > > Thanks for the advice Joshua. I find these tips very useful. However, how > would I close the files, or would they cl

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Devyn Collier Johnson
On 08/05/2013 11:12 PM, Joshua Landau wrote: On 6 August 2013 03:00, Devyn Collier Johnson <mailto:devyncjohn...@gmail.com>> wrote: I am wanting to sort a plain text file alphanumerically by the lines. I have tried this code, but I get an error. I assume this command

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Devyn Collier Johnson
On 08/05/2013 11:49 PM, alex23 wrote: On 6/08/2013 1:12 PM, Joshua Landau wrote: Because it's bad to open files without a with unless you know what you're doing, use a with: with open('/home/collier/pytest/__sort.TXT') as file: sorted(file, key=str.casefold, reverse=True) Shoul

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Devyn Collier Johnson
On 08/05/2013 10:19 PM, MRAB wrote: On 06/08/2013 03:00, Devyn Collier Johnson wrote: I am wanting to sort a plain text file alphanumerically by the lines. I have tried this code, but I get an error. I assume this command does not accept newline characters. >>> file = open('

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Devyn Collier Johnson
On 08/05/2013 10:19 PM, MRAB wrote: On 06/08/2013 03:00, Devyn Collier Johnson wrote: I am wanting to sort a plain text file alphanumerically by the lines. I have tried this code, but I get an error. I assume this command does not accept newline characters. >>> file = open('

Re: Sort lines in a plain text file alphanumerically

2013-08-05 Thread alex23
On 6/08/2013 1:49 PM, alex23 wrote: On 6/08/2013 1:12 PM, Joshua Landau wrote: Because it's bad to open files without a with unless you know what you're doing, use a with: with open('/home/collier/pytest/__sort.TXT') as file: sorted(file, key=str.casefold, reverse=True) Shouldn'

Re: Sort lines in a plain text file alphanumerically

2013-08-05 Thread alex23
On 6/08/2013 1:49 PM, alex23 wrote: Shouldn't that be: with open('/home/collier/pytest/__sort.TXT') as file: data = file.readlines() sorted(data, key=str.casefold, reverse=True) I'm tempted to say "HINT #5: don't provide a solution without testing it first" but that would

Re: Sort lines in a plain text file alphanumerically

2013-08-05 Thread alex23
On 6/08/2013 1:12 PM, Joshua Landau wrote: Because it's bad to open files without a with unless you know what you're doing, use a with: with open('/home/collier/pytest/__sort.TXT') as file: sorted(file, key=str.casefold, reverse=True) Shouldn't that be: with open('/home/coll

Re: Sort lines in a plain text file alphanumerically

2013-08-05 Thread edu4madh
On Monday, August 5, 2013 10:00:55 PM UTC-4, Devyn Collier Johnson wrote: > I am wanting to sort a plain text file alphanumerically by the lines. I > > have tried this code, but I get an error. I assume this command does not > > accept newline characters. > > >

Re: Sort lines in a plain text file alphanumerically

2013-08-05 Thread Joshua Landau
On 6 August 2013 03:00, Devyn Collier Johnson wrote: > I am wanting to sort a plain text file alphanumerically by the lines. I > have tried this code, but I get an error. I assume this command does not > accept newline characters. > HINT #1: Don't assume that without a r

Re: Sort lines in a plain text file alphanumerically

2013-08-05 Thread MRAB
On 06/08/2013 03:00, Devyn Collier Johnson wrote: I am wanting to sort a plain text file alphanumerically by the lines. I have tried this code, but I get an error. I assume this command does not accept newline characters. >>> file = open('/home/collier/pytest/sort.TXT',

Sort lines in a plain text file alphanumerically

2013-08-05 Thread Devyn Collier Johnson
I am wanting to sort a plain text file alphanumerically by the lines. I have tried this code, but I get an error. I assume this command does not accept newline characters. >>> file = open('/home/collier/pytest/sort.TXT', 'r').read() >>> print(file) z c

Re: Parsing Text file

2013-07-02 Thread Denis McMahon
On Tue, 02 Jul 2013 13:28:33 -0700, sas429s wrote: > Ok here is a snippet of the text file I have: > I hope this helps.. > . > Thanks for your help ok ... so you need to figure out how best to distinguish the filename, then loop through the file, remember each filename as you

Re: Parsing Text file

2013-07-02 Thread Joshua Landau
On 2 July 2013 21:28, wrote: > Here I am looking for the line that contains: "WORK_MODE_MASK", I want to > print that line as well as the file name above it: > config/meal/governor_mode_config.h > or config/meal/components/source/ceal_PackD_kso_aic_core_config.h. > > SO the output should be som

Re: Parsing Text file

2013-07-02 Thread sas429s
Ok here is a snippet of the text file I have: config/meal/governor_mode_config.h #define GOVERNOR_MODE_TASK_RATE SSS_TID_0015MSEC #define GOVERNOR_MODE_WORK_MODE_MASK(CEAL_MODE_WORK_MASK_GEAR| \ CEAL_MODE_WORK_MASK_PARK_BRAKE

Re: Parsing Text file

2013-07-02 Thread Joshua Landau
On 2 July 2013 20:50, Tobiah wrote: > How do we know whether we have Sometext? > If it's really just a literal 'Sometext', then > just print that when you hit maskit. > > Otherwise: > > > for line in open('file.txt').readlines(): > > if is_sometext(line): > memory = line >

Re: Parsing Text file

2013-07-02 Thread Neil Cerutti
On 2013-07-02, Tobiah wrote: > On 07/02/2013 12:30 PM, sas4...@gmail.com wrote: >> Somemore can be anything for instance: >> >> Sometext >> mail >> maskit >> >> Sometext >> rupee >> dollar >> maskit >> >> and so on.. >> >> Is there a way I can achieve this? > > How do we know whether we have Somet

Re: Parsing Text file

2013-07-02 Thread Tobiah
On 07/02/2013 12:30 PM, sas4...@gmail.com wrote: Somemore can be anything for instance: Sometext mail maskit Sometext rupee dollar maskit and so on.. Is there a way I can achieve this? How do we know whether we have Sometext? If it's really just a literal 'Sometext', then just print that wh

Re: Parsing Text file

2013-07-02 Thread sas429s
Somemore can be anything for instance: Sometext mail maskit Sometext rupee dollar maskit and so on.. Is there a way I can achieve this? On Tuesday, July 2, 2013 2:24:26 PM UTC-5, Neil Cerutti wrote: > On 2013-07-02, sas4...@gmail.com wrote: > > > I have a text fi

Re: Parsing Text file

2013-07-02 Thread Neil Cerutti
On 2013-07-02, sas4...@gmail.com wrote: > I have a text file like this: > > Sometext > Somemore > Somemore > maskit > > Sometext > Somemore > Somemore > Somemore > maskit > > Sometext > Somemore > maskit > > I want to search for the string

Parsing Text file

2013-07-02 Thread sas429s
I have a text file like this: Sometext Somemore Somemore maskit Sometext Somemore Somemore Somemore maskit Sometext Somemore maskit I want to search for the string maskit in this file and also need to print Sometext above it..SOmetext location can vary as you can see above. In the first

problem with saving data in a text file

2013-04-23 Thread Debashish Saha
I tried the following: Am_cor=np.vectorize(Am_cor) #plt.plot(t, signal, color='blue', label='Original signal') fig=plt.figure() plt.xlabel('Time(minute)') plt.ylabel('$ Re()$') plt.xlim([t[0], t[-1]]) plt.ylim((-.3*a1-a1,a1+.3*a1)) plt.grid() plt.plot(t,Am_cor(t),'o-',label='with parallax', marke

Re: How to make a Python script to audio read a text file on phone ?

2013-03-17 Thread dey . sumit . kr
On Sunday, March 17, 2013 7:34:18 PM UTC+5:30, Nic wrote: > I've installed Python on my Nokia E71 (Symbian S60 3rd FP1) and found a > script example which can read out text, see example below. > > I want to make the script to asks me for a text file instead and then reads >

How to make a Python script to audio read a text file on phone ?

2013-03-17 Thread Nic
I've installed Python on my Nokia E71 (Symbian S60 3rd FP1) and found a script example which can read out text, see example below. I want to make the script to asks me for a text file instead and then reads out the content. I guess it works with a .txt file, dont know if other formats

Re: read and write the same text file

2013-03-09 Thread Steven D'Aprano
On Sat, 09 Mar 2013 10:47:34 -0500, Roy Smith wrote: > In article , > iMath wrote: >> def text_process(file): >> with open(file,'r') as f: >> text = f.read() >> with open(file,'w') as f: >> f.write(replace_pattern.sub('',text)) > > At a minimum, you need to close the fi

Re: read and write the same text file

2013-03-09 Thread Roy Smith
In article , iMath wrote: > read and write the same text file > Open a text file ,read the content ,then make some change on it ,then write > it back to the file ,now the modified text should only has the modified > content but not the initial content ,so can we implement this

read and write the same text file

2013-03-09 Thread iMath
read and write the same text file Open a text file ,read the content ,then make some change on it ,then write it back to the file ,now the modified text should only has the modified content but not the initial content ,so can we implement this by only set the mode parameter with open

Re: create object base on text file

2013-01-25 Thread cxleung
x > > > > > > PrinterB > > > print Production batch4 > > > xxx > > >print Production batch5 > > > > > > > > > > > >

Re: create object base on text file

2013-01-25 Thread Dave Angel
xxx PrinterB print Production batch4 xxx print Production batch5 What to using python create object base on date file ? I know how to read text file. object["PrinterA"] ha

create object base on text file

2013-01-25 Thread moonhkt
Production batch4 xxx print Production batch5 What to using python create object base on date file ? I know how to read text file. object["PrinterA"] have batch1, batch2, batch3 object["PrinterB

Re: print or write on a text file ?

2012-10-01 Thread nn
On Sep 28, 2:42 pm, Franck Ditter wrote: > Hi ! > Here is Python 3.3 > Is it better in any way to use print(x,x,x,file='out') > or out.write(x) ? Any reason to prefer any of them ? > There should be a printlines, like readlines ? > Thanks, > >     franck There is out.writelines(lst) -- http://m

Re: print or write on a text file ?

2012-09-28 Thread Terry Reedy
On 9/28/2012 2:42 PM, Franck Ditter wrote: Hi ! Here is Python 3.3 Is it better in any way to use print(x,x,x,file='out') or out.write(x) ? Any reason to prefer any of them ? print converts objects to strings and adds separators and terminators. If you have a string s and want to output it as

Re: print or write on a text file ?

2012-09-28 Thread Wayne Werner
the end of what it prints. So if you had text = 'Hello!' and you did: print(text, file=outfile) then outfile would contain 'Hello!\n' In contrast, outfile.write(text) would only write 'Hello!'. No newline. There are lots of other handy things you can do wit

print or write on a text file ?

2012-09-28 Thread Franck Ditter
Hi ! Here is Python 3.3 Is it better in any way to use print(x,x,x,file='out') or out.write(x) ? Any reason to prefer any of them ? There should be a printlines, like readlines ? Thanks, franck -- http://mail.python.org/mailman/listinfo/python-list

Re: using text file to get ip address from hostname

2012-09-19 Thread Dan Katorza
> > > > > > Yep! Look up the docs and tutorial on "control flow" and "looping > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > constructs". Sounds like

Re: using text file to get ip address from hostname

2012-09-19 Thread Dave Angel
;) >> print ("#####") >> print ("# Choose from the options below #") >> print ("# 1- url , 2-File(Text file only.txt) #") >> print ("#

Re: using text file to get ip address from hostname

2012-09-19 Thread Dan Katorza
> > > constructs". Sounds like what you want here is a 'while' loop. > > > > > > > > > > > > > > > > > > > > > > > > > > > > ChrisA > > > > > > > > > >

Re: using text file to get ip address from hostname

2012-09-19 Thread Dan Katorza
gt; > > > > constructs". Sounds like what you want here is a 'while' loop. > > > > > > > > > > > > ChrisA > > > > Hi Chris, > > this is my code: > > > > #!/usr/bin/env python > > #Get the IP Address > > > >

Re: using text file to get ip address from hostname

2012-09-19 Thread Chris Angelico
On Wed, Sep 19, 2012 at 6:50 PM, Dan Katorza wrote: > i know about the while loop , but forgive me i just don't have a clue how to > use it for this situation. You've already used one. What you need to do is surround your entire code with the loop, so that as soon as it gets to the bottom, it go

Re: using text file to get ip address from hostname

2012-09-19 Thread Dan Katorza
llo, please enter file name here> ") if filename.endswith(".txt"): try: infile = open(filename) except EnvironmentError as e: print(e) sys.exit(1) print("\nFile {0} exists!".format(filename)) print("\nGetting IP addresses for hosts"

Re: using text file to get ip address from hostname

2012-09-19 Thread Chris Angelico
On Wed, Sep 19, 2012 at 5:41 PM, Dan Katorza wrote: > > Hello again, > I have another question and i hope you will understand me.. > Is there any option where you can set the program to go back to lets say the > top of the code? > I mean if the program finished the operation and i want to stay in

Re: using text file to get ip address from hostname

2012-09-19 Thread Dan Katorza
t; -- > > > > > > #!/usr/bin/env python > > > > > > #Get the IP Address > > > > > >

Re: using text file to get ip address from hostname

2012-09-17 Thread Thomas Rachel
Am 15.09.2012 18:20 schrieb Dan Katorza: hello again friends, thanks for everyone help on this. i guess i figured it out in two ways. the second one i prefer the most. i will appreciate if someone can give me some tips. thanks again so... ---

Re: using text file to get ip address from hostname

2012-09-15 Thread Dan Katorza
. > > > > this is what i have so far > > -- > > #!/usr/bin/env python > > #Get the IP Address > > > > import socket > > hostname = 'need it to read from a text file

Re: using text file to get ip address from hostname

2012-09-15 Thread Hans Mulder
t; i need to get an ip address from list of hostnames which are in a textfile. >> >> >> >> this is what i have so far >> >> -- >> >> #!/usr/bin/env python >> >> #Ge

Re: using text file to get ip address from hostname

2012-09-15 Thread Dan Katorza
. > > > > this is what i have so far > > -- > > #!/usr/bin/env python > > #Get the IP Address > > > > import socket > > hostname = 'need it to read from a text file

Re: using text file to get ip address from hostname

2012-09-12 Thread Jason Friedman
> i need to get an ip address from list of hostnames which are in a textfile. > > this is what i have so far > -- > #!/usr/bin/env python > #Get the IP Address > > import socket > hostname = '

Re: using text file to get ip address from hostname

2012-09-12 Thread Terry Reedy
On 9/12/2012 10:41 AM, dkato...@gmail.com wrote: it's not really homework, i found a lab exercise on the web > and i;m trying to study with it. maybe not the most efficient way. i have a file with hostnames ordered line by line. Key fact for this exercise: open files are iterable. So your

Re: using text file to get ip address from hostname

2012-09-12 Thread Alister
gt;> >> >> i need to get an ip address from list of hostnames which are in a >> textfile. >> >> >> >> this is what i have so far >> >> -- >> >> #!/usr/

Re: using text file to get ip address from hostname

2012-09-12 Thread dkatorza
ile. > > > > this is what i have so far > > -- > > #!/usr/bin/env python > > #Get the IP Address > > > > import socket > > hostname = 'need it to read from a text

Re: using text file to get ip address from hostname

2012-09-12 Thread Chris Angelico
On Thu, Sep 13, 2012 at 12:24 AM, wrote: > i'm new to Python and i searched the web and could not find an answer for my > issue. > > i need to get an ip address from list of hostnames which are in a textfile. This is sounding like homework, so I'll just give you a basic pointer. You have there

using text file to get ip address from hostname

2012-09-12 Thread dkatorza
ython #Get the IP Address import socket hostname = 'need it to read from a text file' addr = socket.gethostbyname(hostname) print 'The address of ', hostname, 'is', addr --- any idea ? sor

Seeking help: reading text file with genfromtxt

2012-04-04 Thread frankenstein
Hi all I have got a text file which is only 32 MB in size and consists of the following type of lines (columns are fixed): == Header text 1 line ... 01-Jan-2006 0055 145.069 -16.0449 83.2246 84.2835 499.14680 0.074029965 01-Jan-2006 0065

Re: stable object serialization to text file

2012-01-12 Thread K Richard Pixley
On 1/11/12 12:16 , Máté Koch wrote: Hello All, I'm developing an app which stores the data in file system database. The data in my case consists of large python objects, mostly dicts, containing texts and numbers. The easiest way to dump and load them would be pickle, but I have a problem wit

Re: stable object serialization to text file

2012-01-12 Thread Terry Reedy
On 1/12/2012 7:24 AM, Peter Otten wrote: Máté Koch wrote: I'm developing an app which stores the data in file system database. The data in my case consists of large python objects, mostly dicts, containing texts and numbers. The easiest way to dump and load them would be pickle, but I have a pr

Re: stable object serialization to text file

2012-01-12 Thread Máté Koch
That's probably the easiest way as I don't store any binary data just strings and numbers. Thanks! On Jan 12, 2012, at 1:24 PM, Peter Otten wrote: > Máté Koch wrote: > >> I'm developing an app which stores the data in file system database. The >> data in my case consists of large python object

Re: stable object serialization to text file

2012-01-12 Thread Peter Otten
Máté Koch wrote: > I'm developing an app which stores the data in file system database. The > data in my case consists of large python objects, mostly dicts, containing > texts and numbers. The easiest way to dump and load them would be pickle, > but I have a problem with it: I want to keep the da

stable object serialization to text file

2012-01-12 Thread Máté Koch
Hello All, I'm developing an app which stores the data in file system database. The data in my case consists of large python objects, mostly dicts, containing texts and numbers. The easiest way to dump and load them would be pickle, but I have a problem with it: I want to keep the data in versi

stable object serialization to text file

2012-01-11 Thread Máté Koch
Hello All,I'm developing an app which stores the data in file system database. The data in my case consists of large python objects, mostly dicts, containing texts and numbers. The easiest way to dump and load them would be pickle, but I have a problem with it: I want to keep the data in version co

Re: Question about Reading from text file with Python's Array class

2011-12-18 Thread Tim Chase
On 12/18/11 12:33, traveller3141 wrote: To test this, I made a small sample file (sillyNums.txt) as follows; 109 345 2 1234556 f=open("sillyNums.txt","r") data = array.array('i') data.fromstring(f.read(data.itemsize* bufferSize)) print data The output was nonsense: array('i', [171520049, 171258

Re: Question about Reading from text file with Python's Array class

2011-12-18 Thread Peter Otten
traveller3141 wrote: > I've been trying to use the Array class to read 32-bit integers from a > file. There is one integer per line and the integers are stored as text. > For problem specific reasons, I only am allowed to read 2 lines (2 32-bit > integers) at a time. > > To test this, I made a sm

Question about Reading from text file with Python's Array class

2011-12-18 Thread traveller3141
I've been trying to use the Array class to read 32-bit integers from a file. There is one integer per line and the integers are stored as text. For problem specific reasons, I only am allowed to read 2 lines (2 32-bit integers) at a time. To test this, I made a small sample file (sillyNums.txt) as

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: Help parsing a text file

2011-09-01 Thread William Gill
On 9/1/2011 1:58 PM, JT wrote: On Monday, August 29, 2011 1:21:48 PM UTC-5, William Gill wrote: I have a text file with XML like records that I need to parse. By XML like I mean records have proper opening and closing tags. but fields don't have closing tags (they rely on line ends). No

Re: Help parsing a text file

2011-09-01 Thread JT
On Monday, August 29, 2011 1:21:48 PM UTC-5, William Gill wrote: > > I have a text file with XML like records that I need to parse. By XML > like I mean records have proper opening and closing tags. but fields > don't have closing tags (they rely on line ends). Not all fields

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

Text file with mixed end-of-line terminations

2011-08-31 Thread Alex van der Spek
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' Reading this file like this: for line in open(filename,'r'): line= #D

Re: Help parsing a text file

2011-08-30 Thread Tim Roberts
William Gill wrote: > >My initial passes into Python have been very unfocused (a scatter gun of >too many possible directions, yielding very messy results), so I'm >asking for some suggestions, or algorithms (possibly even examples)that >may help me focus. > >I'm not asking anyone to write my c

Re: Help parsing a text file

2011-08-30 Thread Waldek M.
On Mon, 29 Aug 2011 23:05:23 +0200, Thomas Jollans wrote: > A name that is often thrown around on this list for this kind of > question is pyparsing. Now, I don't know anything about it myself, but > it may be worth looking into. Definitely. I did use it and even though it's not perfect - it's ver

Re: Help parsing a text file

2011-08-29 Thread Thomas Jollans
rcome that as the cobwebs clear. Though I do seem to > keep tripping over the same Py2 -> Py3 syntax changes (old habits die > hard). > > I have a text file with XML like records that I need to parse. By XML > like I mean records have proper opening and closing tags. but fields >

Re: Help parsing a text file

2011-08-29 Thread William Gill
On 8/29/2011 2:31 PM, Philip Semanchuk wrote: If the syntax really is close to XML, would it be all that difficult to convert it to proper XML? Then you have nice libraries like ElementTree to use for parsing. Possibly, but I would still need the same search algorithms to find the opening

Re: Help parsing a text file

2011-08-29 Thread Philip Semanchuk
an > overcome that as the cobwebs clear. Though I do seem to keep tripping over > the same Py2 -> Py3 syntax changes (old habits die hard). > > I have a text file with XML like records that I need to parse. By XML like I > mean records have proper opening and closing tags.

Help parsing a text file

2011-08-29 Thread William Gill
keep tripping over the same Py2 -> Py3 syntax changes (old habits die hard). I have a text file with XML like records that I need to parse. By XML like I mean records have proper opening and closing tags. but fields don't have closing tags (they rely on line ends). Not all fields appear i

Re: Arrange files according to a text file

2011-08-27 Thread Ric
No, it turned out to be my mistake. Your code was correct and I appreciate it very much. Thank you again On Sat, 27 Aug 2011 18:10:07 -0700, Emile van Sebille wrote: >On 8/27/2011 4:18 PM r...@rdo.python.org said... >> Thank you so much. The code worked perfectly. >> >> This is what I tried us

Re: Arrange files according to a text file

2011-08-27 Thread Emile van Sebille
On 8/27/2011 4:18 PM r...@rdo.python.org said... Thank you so much. The code worked perfectly. This is what I tried using Emile code. The only time when it picked wrong name from the list was when the file was named like this. Data Mark Stone.doc How can I fix this? Hope I am not asking too mu

Re: Arrange files according to a text file

2011-08-27 Thread Ric
io() for txt_name in >> txt_names] >> best = max(ratios) >> owner = txt_names[ratios.index(best)] >> print filename,":",owner >> >> >> >> >> >> On Sat, 27 Aug 2011 14:08:17 -0700, Emile van Sebille >> wrot

Re: Arrange files according to a text file

2011-08-27 Thread MRAB
o take a look at it closer. My question would it work for a text file list of names about 25k lines and a directory with say 100 files inside? Sure. Emile Thank you once again. On Sat, 27 Aug 2011 11:06:22 -0700, Emile van Sebille wrote: On 8/27/2011 10:03 AM r...@rdo.python.org said...

Re: Arrange files according to a text file

2011-08-27 Thread Stephen Hansen
On 8/27/11 11:06 AM, Emile van Sebille wrote: > from difflib import SequenceMatcher as SM > > def ignore(x): > return x in ' ,.' > > for filename in filenames: > ratios = [SM(ignore,filename,username).ratio() for username in > usernames] > best = max(ratios) > owner = usernames[ra

Re: Arrange files according to a text file

2011-08-27 Thread Ric
mile , >> >> Thank you for the code below as I have not encountered SequenceMatcher >> before and would have to take a look at it closer. >> >> My question would it work for a text file list of names about 25k >> lines and a directory with say 100 files inside? &g

Re: Arrange files according to a text file

2011-08-27 Thread Emile van Sebille
On 8/27/2011 1:15 PM r...@rdo.python.org said... Hello Emile , Thank you for the code below as I have not encountered SequenceMatcher before and would have to take a look at it closer. My question would it work for a text file list of names about 25k lines and a directory with say 100 files

Re: Arrange files according to a text file

2011-08-27 Thread Ric
Hello Emile , Thank you for the code below as I have not encountered SequenceMatcher before and would have to take a look at it closer. My question would it work for a text file list of names about 25k lines and a directory with say 100 files inside? Thank you once again. On Sat, 27 Aug

Re: Arrange files according to a text file

2011-08-27 Thread Emile van Sebille
ignore,filename,username).ratio() for username in usernames] best = max(ratios) owner = usernames[ratios.index(best)] print filename,":",owner Emile I have many files in separate directories, each file name contain a persons name but never in the same spot. I need to find tha

Re: Arrange files according to a text file

2011-08-27 Thread MRAB
On 27/08/2011 18:03, r...@rdo.python.org wrote: Hello, What would be the best way to accomplish this task? I have many files in separate directories, each file name contain a persons name but never in the same spot. I need to find that name which is listed in a large text file in the following

Arrange files according to a text file

2011-08-27 Thread Ric
Hello, What would be the best way to accomplish this task? I have many files in separate directories, each file name contain a persons name but never in the same spot. I need to find that name which is listed in a large text file in the following format. Last name, comma and First name. The last

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\ja

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

Re: text file

2011-06-30 Thread Josh Benner
(lst)) On Thu, Jun 30, 2011 at 5:19 PM, 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

text file

2011-06-30 Thread Siboniso Shangase
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 Data\ja2.mfc Data\ja3.wav Data\ja3.mfc Data\ja4

Re: Change the name with the random names in a text file

2011-06-29 Thread Ulrich Eckhardt
Amaninder Singh wrote: > I am fairly new to the language and programing. I am trying to solve a > problem in a text file. Where names are something like in this manner > [**Name2 (NI) 98**] > > [**Last Name (STitle) 97**] > [**First Name4 (NamePattern1) 93**] > [**Last N

Re: Change the name with the random names in a text file

2011-06-28 Thread Chris Rebert
On Tue, Jun 28, 2011 at 12:17 PM, Amaninder Singh wrote: > Hi Guys, > I am fairly new to the language and programing. I am trying to solve a > problem in a text file. Where names are something like in this  manner > [**Name2 (NI) 98**] > > [**Last Name (STitle) 97**]

Change the name with the random names in a text file

2011-06-28 Thread Amaninder Singh
Hi Guys, I am fairly new to the language and programing. I am trying to solve a problem in a text file. Where names are something like in this manner [**Name2 (NI) 98**] [**Last Name (STitle) 97**] [**First Name4 (NamePattern1) 93**] [**Last Name (NamePattern1) 94**] ([**Name (NI) 95

Re: NEED HELP-process words in a text file

2011-06-26 Thread Cousin Stanley
Steven D'Aprano wrote: > If ONE word in uppercase is read in a SLIGHTLY louder voice, > then naturally it doesn't take much imagination TO READ > EVEN QUITE SHORT PASSAGES OF UNINTERRUPTED UPPERCASE WORDS > AS SHOUTING LOUDLY -- And it doesn't take much of a reality check through my own

Re: NEED HELP-process words in a text file

2011-06-24 Thread Ethan Furman
Steven D'Aprano wrote: On Fri, 24 Jun 2011 19:17:29 +, Cousin Stanley wrote: Chris Rebert wrote: Netiquette comment: Please avoid SHOUTING The brilliant beam of light that first thought capitilized words amounted to shouting never programmed cobol, fortran, or pl/1 in the 1960

Re: NEED HELP-process words in a text file

2011-06-24 Thread Steven D'Aprano
On Fri, 24 Jun 2011 19:17:29 +, Cousin Stanley wrote: > Chris Rebert wrote: > >> Netiquette comment: Please avoid SHOUTING > > The brilliant beam of light that first thought capitilized words > amounted to shouting never programmed cobol, fortran, or pl/1 in the > 1960s or 1970s .

Re: NEED HELP-process words in a text file

2011-06-24 Thread Cousin Stanley
John Gordon wrote: > In Cousin Stanley > writes: > >> How or why this behavior was cultivated >> and continues to spread is mind boggling > > The behavior of writing in all caps, > or the behavior of equating such writing with shouting ? The latter equating writing in all c

Re: NEED HELP-process words in a text file

2011-06-24 Thread John Gordon
In Cousin Stanley writes: > How or why this behavior was cultivated > and continues to spread is mind boggling The behavior of writing in all caps, or the behavior of equating such writing with shouting? -- John Gordon A is for Amy, who fell down the stairs gor...@pan

<    1   2   3   4   5   6   7   8   9   10   >