Re: NEED HELP-process words in a text file

2011-06-24 Thread Cousin Stanley
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 :-) How or why this behavior was cultivated and contin

Re: NEED HELP-process words in a text file

2011-06-19 Thread Stefan Behnel
Cathy James, 19.06.2011 01:21: def fileProcess(filename): """Call the program with an argument, it should treat the argument as a filename, splitting it up into words, and computes the length of each word. print a table showing the word count for each of the word lengths that

Re: NEED HELP-process words in a text file

2011-06-18 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Cathy James wrote: Dear Python Experts, First, I'd like to convey my appreciation to you all for your support and contributions. I am a Python newborn and need help with my function. I commented on my program as to what it should do, but nothing is printing. I know I

Re: NEED HELP-process words in a text file

2011-06-18 Thread Chris Rebert
On Sat, Jun 18, 2011 at 4:21 PM, Cathy James wrote: > Dear Python Experts, > > First, I'd like to convey my appreciation to you all for your support > and contributions.  I am a Python newborn and need help with my > function. I commented on my program as to what it should do, but > nothing is pri

Re: NEED HELP-process words in a text file

2011-06-18 Thread Tim Chase
On 06/18/2011 06:21 PM, Cathy James wrote: freq = [] #empty dict to accumulate words and word length While you say you create an empty dict, using "[]" creates an empty *list*, not a dict. Either your comment is wrong or your code is wrong. :) Given your usage, I presume you want a di

Re: NEED HELP-process words in a text file

2011-06-18 Thread Chris Rebert
On Sat, Jun 18, 2011 at 4:21 PM, Cathy James wrote: > Subject: NEED HELP-process words in a text file > > Dear Python Experts, > > First, I'd like to convey my appreciation to you all for your support > and contributions.  I am a Python newborn and need help with my > f

NEED HELP-process words in a text file

2011-06-18 Thread Cathy James
Dear Python Experts, First, I'd like to convey my appreciation to you all for your support and contributions. I am a Python newborn and need help with my function. I commented on my program as to what it should do, but nothing is printing. I know I am off, but not sure where. Please help:( impor

RE: list from FTP server to a text file

2011-01-06 Thread Ahmed, Shakir
-Original Message- From: python-list-bounces+shahmed=sfwmd@python.org [mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of Dan M Sent: Thursday, January 06, 2011 11:06 AM To: python-list@python.org Subject: Re: list from FTP server to a text file On Thu, 06 Jan

Re: list from FTP server to a text file

2011-01-06 Thread Dan M
On Thu, 06 Jan 2011 10:51:42 -0500, Ahmed, Shakir wrote: > Hi, > > I am trying to create a list in a txt file from an ftp server. The > following code is retrieving the list of the files but could not able to > write in a text file. Any help is highly appreciat

list from FTP server to a text file

2011-01-06 Thread Ahmed, Shakir
Hi, I am trying to create a list in a txt file from an ftp server. The following code is retrieving the list of the files but could not able to write in a text file. Any help is highly appreciated. Thanks import os import time from ftplib import FTP ftp = FTP

Re: OSError: [Errno 26] Text file busy during subprocess.check_call() :seems os dependent

2010-12-30 Thread Nobody
On Thu, 30 Dec 2010 13:46:35 -0800, harijay wrote: > Each Thread receives a dynamically generated shell script from some > classes I wrote and then runs the script using > > subprocess.call(["shell_script_file.sh"]) > But I get the same "OSError: [Errno 26] Text

Re: OSError: [Errno 26] Text file busy during subprocess.check_call() :seems os dependent

2010-12-30 Thread Steven D'Aprano
On Thu, 30 Dec 2010 13:46:35 -0800, harijay wrote: [...] > But I get the same "OSError: [Errno 26] Text file busy" error > > Everytime I run the same job queue a different part of the job fails. > > Unfortunately I dont see anybody else reporting this OSError. ANy hel

Re: OSError: [Errno 26] Text file busy during subprocess.check_call() :seems os dependent

2010-12-30 Thread harijay
have dynamically generated and unique filenames > > Most often I see references to binary executable files for the error > message, but I've also seen references to script files, e.g. >      http://www.cyberciti.biz/faq/binbash-bad-interpreter-text-file-busy/ > > > > >

Re: OSError: [Errno 26] Text file busy during subprocess.check_call() :seems os dependent

2010-12-30 Thread Terry Reedy
On 12/30/2010 4:46 PM, harijay wrote: "OSError: [Errno 26] Text file busy" error Searching 'errno 26', the third Google response suggests that you are trying to write to a file (especially an executable or shared library?) that is already in use. Perhaps just trying to r

Re: OSError: [Errno 26] Text file busy during subprocess.check_call() :seems os dependent

2010-12-30 Thread Thomas L. Shinnick
ynamically generated and unique filenames Most often I see references to binary executable files for the error message, but I've also seen references to script files, e.g. http://www.cyberciti.biz/faq/binbash-bad-interpreter-text-file-busy/ I tested the code on a mac laptop and

OSError: [Errno 26] Text file busy during subprocess.check_call() :seems os dependent

2010-12-30 Thread harijay
og","w") But I get the same "OSError: [Errno 26] Text file busy" error Everytime I run the same job queue a different part of the job fails. Unfortunately I dont see anybody else reporting this OSError. ANy help in troubleshooting my "newbie" thread cod

Re: Read time and date from a text file

2010-11-24 Thread huisky
On Nov 24, 2:45 pm, Peter Otten <__pete...@web.de> wrote: > huisky wrote: > > I see the problem of year. But the question is the source file does > > NOT provide the year information. > > for instance if i have one record as ['Dec','6','21:01:17'], and the > > other as ['Jan','6','21:01:17'] > > th

Re: Read time and date from a text file

2010-11-24 Thread Peter Otten
huisky wrote: > I see the problem of year. But the question is the source file does > NOT provide the year information. > for instance if i have one record as ['Dec','6','21:01:17'], and the > other as ['Jan','6','21:01:17'] > these two records may be in different year. Will it be a problem to > u

Re: Read time and date from a text file

2010-11-24 Thread huisky
On Nov 24, 2:09 pm, Peter Otten <__pete...@web.de> wrote: > huisky wrote: > > As a newbie, I posted my question here again. > > say i have two dics read from a text file by 'split'. > > Please don't start a new thread when you are still aski

Re: Read time and date from a text file

2010-11-24 Thread Peter Otten
huisky wrote: > As a newbie, I posted my question here again. > say i have two dics read from a text file by 'split'. Please don't start a new thread when you are still asking about the same topic. >>>> cstart > > defaultdict(, {15424: ['Dec'

Re: Read time and date from a text file

2010-11-24 Thread Tim Williams
On Nov 24, 7:45 am, huisky wrote: > Hi, > > As a newbie, I posted my question here again. > say i have two dics read from a text file by 'split'. > > >>> cstart > > defaultdict(, {15424: ['Dec', '6', '18:57:40'], 552: &g

Read time and date from a text file

2010-11-24 Thread huisky
Hi, As a newbie, I posted my question here again. say i have two dics read from a text file by 'split'. >>> cstart defaultdict(, {15424: ['Dec', '6', '18:57:40'], 552: ['Dec', '7', '09:31:00'], 15500: ['De

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 ;

text file reformatting

2010-10-31 Thread iwawi
I have this fixed width data file (data.txt) which I would like to reformat. Data is something like this, with hundreds of rows and columns, every row finishes to END: PRJ01001 4 00100END PRJ01002 3 00110END PRJ01003 3 00120END PRJ01004 2 00130END PRJ01005 1 00140END PRJ01006 1 00150END PRJ01007 3

Re: accessing a text file

2010-09-16 Thread Baba
On Sep 9, 10:09 pm, Nobody wrote: > On Wed, 08 Sep 2010 03:30:00 -0700, Baba wrote: > > Who is licensed to judge what can and cannot be posted as a question? > > Exactly the same set of people who are licensed to judge what can and > cannot be posted as an answer. > > If you don't like the respons

Re: accessing a text file

2010-09-09 Thread Paul Rubin
Nobody writes: > If you don't like the responses you get here, you could try posting your > questions on 4chan. If nothing else, that will give you a whole new > perspective on what an "unfriendly" response really looks like. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: accessing a text file

2010-09-09 Thread Nobody
On Wed, 08 Sep 2010 03:30:00 -0700, Baba wrote: > Who is licensed to judge what can and cannot be posted as a question? Exactly the same set of people who are licensed to judge what can and cannot be posted as an answer. If you don't like the responses you get here, you could try posting your qu

Re: accessing a text file

2010-09-08 Thread Grant Edwards
On 2010-09-09, Ben Finney wrote: > Grant Edwards writes: > >> I'm sure you'd prefer that everything was handed to you for free on a >> silver platter with a side order of beer and cookies. I'd prefer I was >> 20 years younger and 30 pounds lighter. Life's tough that way. > > Hell no. I'd prefer t

Re: accessing a text file

2010-09-08 Thread Ben Finney
Grant Edwards writes: > I'm sure you'd prefer that everything was handed to you for free on a > silver platter with a side order of beer and cookies. I'd prefer I was > 20 years younger and 30 pounds lighter. Life's tough that way. Hell no. I'd prefer to have the total of my life experience and

Re: accessing a text file

2010-09-08 Thread Ben Finney
Baba writes: > Thanks for your feedback. My question is: Who owns this forum? If we > all do then we are allowed to post questions that are simple and that > could otherwise be answered by doing research. That's a rather subservient perspective. Why are you seeking permission to ask questions? W

Re: accessing a text file

2010-09-08 Thread MRAB
On 08/09/2010 23:56, Bar Shirtcliff wrote: | HEREow can you be learning so much python if you're constantly expressing typo there. I'm not sure how that happens, sometimes, but it's an untimely abbrev-expansion, in emacs VM. I meant to say, "How can you..." An unkind soul would say that "it'

Re: accessing a text file

2010-09-08 Thread Bar Shirtcliff
| HEREow can you be learning so much python if you're constantly expressing typo there. I'm not sure how that happens, sometimes, but it's an untimely abbrev-expansion, in emacs VM. I meant to say, "How can you..." Cheers, Bar -- http://mail.python.org/mailman/listinfo/python-list

Re: accessing a text file

2010-09-08 Thread Bar Shirtcliff
| Hi Paul | | If i look where i was 4 weeks ago and the progress i made in learning | Python i am quite delighted. This forum has helped me and i appreciate | it. I don't think i will ever tell a beginner to "do me a favour" and | to look things up by himself nor will i use the RTFM line (refering

Re: accessing a text file

2010-09-08 Thread Baba
On 8 sep, 14:39, Paul Rubin wrote: > Baba writes: > > But where do you draw the line? Can we not just let people ask > > questions regardless? And let those answer who want to and those who > > don't just ignore the question? That seems so much easier to me. > > The first few times, it's easy to

Re: accessing a text file

2010-09-08 Thread Bruno Desthuilliers
Baba a écrit : "Dear xyz, Your question can easily be researched online. We suggest you give it a try and to look it up yourself. This will be beneficial both to you and to us. We do encourage to ask questions only when they have been researched first." On usenet - as well as on most technical

Re: accessing a text file

2010-09-08 Thread Grant Edwards
On 2010-09-08, Baba wrote: > Thanks for your feedback. My question is: Who owns this forum? If we > all do then we are allowed to post questions that are simple and that > could otherwise be answered by doing research. Of course you're allowed to post such questions. And people are allowed to i

Re: accessing a text file

2010-09-08 Thread Paul Rubin
Baba writes: > But where do you draw the line? Can we not just let people ask > questions regardless? And let those answer who want to and those who > don't just ignore the question? That seems so much easier to me. The first few times, it's easy to ignore the questions. After a few more times,

Re: accessing a text file

2010-09-08 Thread Baba
On 8 sep, 12:46, Paul Rubin wrote: > Baba writes: > > It is just unfriendly > > to tell someone to go and look it up by themselves. > > Someone seeing too many unthoughtful questions from you might tell you > to look it up yourself, in the hopes of getting you to change your > questioning style,

Re: accessing a text file

2010-09-08 Thread Paul Rubin
Baba writes: > It is just unfriendly > to tell someone to go and look it up by themselves. Someone seeing too many unthoughtful questions from you might tell you to look it up yourself, in the hopes of getting you to change your questioning style, so that your future questions will be more though

Re: accessing a text file

2010-09-08 Thread Baba
eve me, documentation can be offputting too when you only start with programming. Per se the beauty of forums like these is that there are human beings willing to make such tasks as finding out how to access a text file less 'scary'. Whoever thinks he or she has a license to tell someone

Re: accessing a text file

2010-09-07 Thread Ben Finney
Baba writes: > However the following Wiki excerpt seems to go in my direction: No, it doesn't. It advises that people show kindness; as I've been arguing, that's exactly what you were shown. You haven't shown how the information being imparted could have been fully imparted in a way that's kinde

Re: accessing a text file

2010-09-07 Thread Baba
On 7 sep, 16:50, Grant Edwards wrote: > On 2010-09-07, Baba wrote: > > > Sloppy wording, I apologise. This should say: If you find the > > question you're reading too easy then just don't answer. Noone is the > > owner of a democratic forum where freedom to ask the question one > > likes is param

Re: accessing a text file

2010-09-07 Thread geremy condra
On Tue, Sep 7, 2010 at 4:39 AM, Baba wrote: > On 7 sep, 02:18, Ben Finney wrote: >> Ben Finney writes: >> > We value respect for people here, and that's what you've been shown >> > consistently. But respect for opinions, or for delicacy about >> > learning, is not welcome here. >> >> Sloppy word

Re: accessing a text file

2010-09-07 Thread Grant Edwards
On 2010-09-07, Baba wrote: > Sloppy wording, I apologise. This should say: If you find the > question you're reading too easy then just don't answer. Noone is the > owner of a democratic forum where freedom to ask the question one > likes is paramount (as long of course as it is related to the >

Re: accessing a text file

2010-09-07 Thread Ben Finney
Baba writes: > to say "Please do us a favour and at least try to figure things out on > your own" is in my view inappropriate. That's what the person wanted you to see. How would you prefer that exact information to be imparted to you? How could it have been communicated so that it was not misun

Re: accessing a text file

2010-09-07 Thread Bruno Desthuilliers
Baba a écrit : (snip) If i had received a friendly response from Benjamin (as opposed to "Please do us a favor and at least try to figure things out on your own") According to usenet standards and given your initial question, this is a _very_ friendly answer. -- http://mail.python.org/mailman

Re: accessing a text file

2010-09-07 Thread Baba
On 7 sep, 13:39, Baba wrote: > On 7 sep, 02:18, Ben Finney wrote: > > > > > > > Ben Finney writes: > > > We value respect for people here, and that's what you've been shown > > > consistently. But respect for opinions, or for delicacy about > > > learning, is not welcome here. > > > Sloppy wordi

Re: accessing a text file

2010-09-07 Thread Baba
On 7 sep, 02:18, Ben Finney wrote: > Ben Finney writes: > > We value respect for people here, and that's what you've been shown > > consistently. But respect for opinions, or for delicacy about > > learning, is not welcome here. > > Sloppy wording, I apologise. This should say “… is not respect f

Re: accessing a text file

2010-09-06 Thread Ben Finney
Ben Finney writes: > We value respect for people here, and that's what you've been shown > consistently. But respect for opinions, or for delicacy about > learning, is not welcome here. Sloppy wording, I apologise. This should say “… is not respect for a person”. > In other words, we treat peop

Re: accessing a text file

2010-09-06 Thread Ben Finney
Baba writes: > Thanks Jeremy, i will take your advice on board! Noone likes to be > taught lessons i think so it is only normal that i reacted. Please reconsider this response. Many of us use this forum precisely because we *do* like to be taught lessons. If you don't want to be taught lessons,

Re: accessing a text file

2010-09-06 Thread Baba
> On Sun, Sep 5, 2010 at 5:47 PM, Baba wrote: > >> > > > level: beginner > > >> > > > how can i access the contents of a text file in Python? > > >> > > > i would like to compare a string (word) with the content of a text > >>

Re: accessing a text file

2010-09-06 Thread geremy condra
wrote: >> > > > level: beginner >> >> > > > how can i access the contents of a text file in Python? >> >> > > > i would like to compare a string (word) with the content of a text >> > > > file (word_list). i want to see if

Re: accessing a text file

2010-09-06 Thread Baba
On 6 sep, 16:58, Thomas Jollans wrote: > On Monday 06 September 2010, it occurred to Baba to exclaim: > > > > > On 6 sep, 00:01, Benjamin Kaplan wrote: > > > On Sun, Sep 5, 2010 at 5:47 PM, Baba wrote: > > > > level: beginner > > > > >

Re: accessing a text file

2010-09-06 Thread Thomas Jollans
On Monday 06 September 2010, it occurred to Baba to exclaim: > On 6 sep, 00:01, Benjamin Kaplan wrote: > > On Sun, Sep 5, 2010 at 5:47 PM, Baba wrote: > > > level: beginner > > > > > > how can i access the contents of a text file in Python? > > >

Re: accessing a text file

2010-09-06 Thread Baba
On 6 sep, 00:04, Seth Rees wrote: > On 09/05/10 16:47, Baba wrote: > > > level: beginner > > > how can i access the contents of a text file in Python? > > > i would like to compare a string (word) with the content of a text > > file (word_list). i want to see i

Re: accessing a text file

2010-09-06 Thread Baba
On 6 sep, 00:01, Benjamin Kaplan wrote: > On Sun, Sep 5, 2010 at 5:47 PM, Baba wrote: > > level: beginner > > > how can i access the contents of a text file in Python? > > > i would like to compare a string (word) with the content of a text > > file (word_l

Re: accessing a text file

2010-09-05 Thread Zhu Sha Zang
Em 05-09-2010 19:06, Alexander Kapps escreveu: > Baba wrote: >> level: beginner >> >> how can i access the contents of a text file in Python? >> >> i would like to compare a string (word) with the content of a text >> file (word_list). i want to see if wo

Re: accessing a text file

2010-09-05 Thread Alexander Kapps
Baba wrote: level: beginner how can i access the contents of a text file in Python? i would like to compare a string (word) with the content of a text file (word_list). i want to see if word is in word_list. let's assume the TXT file is stored in the same directory as the PY file.

Re: accessing a text file

2010-09-05 Thread MRAB
On 05/09/2010 22:47, Baba wrote: level: beginner how can i access the contents of a text file in Python? That's a very basic question. I suggest you read a tutorial such as "Dive Into Python": http://diveintopython.org/toc/index.html i would like to compare a string

Re: accessing a text file

2010-09-05 Thread Benjamin Kaplan
On Sun, Sep 5, 2010 at 5:47 PM, Baba wrote: > level: beginner > > how can i access the contents of a text file in Python? > > i would like to compare a string (word) with the content of a text > file (word_list). i want to see if word is in word_list. let's assume > the

Re: accessing a text file

2010-09-05 Thread Seth Rees
On 09/05/10 16:47, Baba wrote: > level: beginner > > how can i access the contents of a text file in Python? > > i would like to compare a string (word) with the content of a text > file (word_list). i want to see if word is in word_list. let's assume > the TXT

Re: accessing a text file

2010-09-05 Thread Nitin Pawar
may be something like this f = open ("file",r) data = f.read() f.close if word in data: print word, "is present in file" On Mon, Sep 6, 2010 at 3:17 AM, Baba wrote: > level: beginner > > how can i access the contents of a text file in Python? > > i w

accessing a text file

2010-09-05 Thread Baba
level: beginner how can i access the contents of a text file in Python? i would like to compare a string (word) with the content of a text file (word_list). i want to see if word is in word_list. let's assume the TXT file is stored in the same directory as the PY file. def is_valid_word

Re: float from numbers in text file

2010-06-21 Thread davidgp
On Jun 21, 5:13 pm, Stephen Hansen wrote: > On 6/21/10 4:26 PM, davidgp wrote: > > > > > > > ah, i see :P > > float("45.34") or whatever does work fine, but the problem is that i'm > > reading it from a text file. so somehow it is not a real str

Re: float from numbers in text file

2010-06-21 Thread Stephen Hansen
On 6/21/10 4:26 PM, davidgp wrote: > ah, i see :P > float("45.34") or whatever does work fine, but the problem is that i'm > reading it from a text file. so somehow it is not a real string or > whatever.. > here's a part of the code: > f = open ('/home/da

Re: float from numbers in text file

2010-06-21 Thread GMail Felipe
found') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for float(): not found -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog:http://meh.ixokai.io/ signature.asc < 1KViewDownload ah, i see

Re: float from numbers in text file

2010-06-21 Thread davidgp
quot;line", for whatever reason, contains the string "not found", as in: > > >>> float('not found') > > Traceback (most recent call last): >   File "", line 1, in > ValueError: invalid literal for float(): not found > > -- > &g

Re: float from numbers in text file

2010-06-21 Thread Stephen Hansen
On 6/21/10 4:03 PM, davidgp wrote: > > sorry :) Okay, I should be more specific: include full tracebacks and some real copied and pasted code :) Don't throw away nice debugging information Python gave you, feed it to us. > invalid literal for long() with base 10: '51.9449702' > this is the error

Re: float from numbers in text file

2010-06-21 Thread davidgp
On Jun 21, 4:00 pm, Stephen Hansen wrote: > On 6/21/10 3:54 PM, davidgp wrote: > > > i basically tried this: > > lat =0.0 > > for line in f: > >   lat = float(line) > > > but this gives an error.. does anyone know what i should to do? > > thanks, > > "An error"? > > Python 2.6.1 (r261:67515, Feb 1

Re: float from numbers in text file

2010-06-21 Thread Stephen Hansen
On 6/21/10 3:54 PM, davidgp wrote: > i basically tried this: > lat =0.0 > for line in f: > lat = float(line) > > but this gives an error.. does anyone know what i should to do? > thanks, "An error"? Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin

float from numbers in text file

2010-06-21 Thread davidgp
hello, i have a text file that contains gps coordinates that i want to load into my mysql database the file is basically in this format: 52.2375412 5.1802704 i basically tried this: lat =0.0 for line in f: lat = float(line) but this gives an error.. does anyone know what i should to do? thanks

Re: Replace in large text file ?

2010-06-09 Thread Tim Chase
On 06/09/2010 05:27 AM, hiral wrote: On Jun 6, 7:27 am, Steve wrote: On 5 June, 08:53, Steve wrote: Remove all comma's Replace all @ with comma's Save as a new file. Many thanks for your suggestions. sed -i 's/Hello/hello/g' file Run twice on the CL..with the hello's changed for my needs

Re: Replace in large text file ?

2010-06-09 Thread hiral
On Jun 6, 7:27 am, Steve wrote: > On 5 June, 08:53, Steve wrote: > > > I am new to Python and am wanting  to replace characters in a very > > large text file.6 GB > > In plain language what I wish to do is: > > > Remove all comma's > > Repla

Re: Replace in large text file ?

2010-06-06 Thread Nobody
On Sat, 05 Jun 2010 16:35:42 +0100, MRAB wrote: >>> In plain language what I wish to do is: >>> >>> Remove all comma's >>> Replace all @ with comma's >> input_file = open("some_huge_file.txt", "r") >> output_file = open("newfilename.txt", "w") >> for line in input_file: > I'd probably process it

Re: Replace in large text file ?

2010-06-06 Thread Eknath Venkataramani
On Sat, Jun 5, 2010 at 1:23 PM, Steve wrote: > > Remove all comma's > Replace all @ with comma's > Save as a new file. > Why don't you use 'sed'. It'd be way faster -- Eknath Venkataramani -- http://mail.python.org/mailman/listinfo/python-list

Re: Replace in large text file ?

2010-06-05 Thread Steve
On 5 June, 08:53, Steve wrote: > I am new to Python and am wanting  to replace characters in a very > large text file.6 GB > In plain language what I wish to do is: > > Remove all comma's > Replace all @ with comma's > Save as a new file. > > Any of you

Re: Replace in large text file ?

2010-06-05 Thread MRAB
Steven D'Aprano wrote: On Sat, 05 Jun 2010 00:53:23 -0700, Steve wrote: I am new to Python and am wanting to replace characters in a very large text file.6 GB In plain language what I wish to do is: Remove all comma's Replace all @ with comma's Save as a new file. in

Re: Replace in large text file ?

2010-06-05 Thread Gabriele Lanaro
A module designed to do this is fileinput: http://docs.python.org/library/fileinput.html The approach is the same as the other except that it's in the standard library. 2010/6/5 Paul Rubin > Steve writes: > > Remove all comma's > > Replace all @ with comma's > > Save as a new file. > > The si

Re: Replace in large text file ?

2010-06-05 Thread Paul Rubin
Steve writes: > Remove all comma's > Replace all @ with comma's > Save as a new file. The simplest way is just copy the file one character at a time, making replacements to commas and @'s as stated. That will be a bit slow (especially in Python) but if you only have to do it once, just wait it o

Re: Replace in large text file ?

2010-06-05 Thread Steven D'Aprano
On Sat, 05 Jun 2010 00:53:23 -0700, Steve wrote: > I am new to Python and am wanting to replace characters in a very large > text file.6 GB > In plain language what I wish to do is: > > Remove all comma's > Replace all @ with comma's > Save as

Re: extract substring by regex from a text file

2010-04-17 Thread Alessio
On Apr 17, 11:05 am, Peter Otten <__pete...@web.de> wrote: > > Just in case you didn't know: > >     for line in instream: >         ... > > looks better, uses less memory, and may be a tad faster than > >     for line in instream.readlines(): >         ... > > Peter Thanks for your suggestions, t

Re: extract substring by regex from a text file

2010-04-17 Thread Peter Otten
Alessio wrote: > I used readlines() to read my text file, then with a for cicle I > extract line by line the substrings I need by regular expressions Just in case you didn't know: for line in instream: ... looks better, uses less memory, and may be a tad faster than

Re: extract substring by regex from a text file

2010-04-17 Thread Stefan Behnel
Alessio, 17.04.2010 10:19: I used readlines() to read my text file, then with a for cicle I extract line by line the substrings I need by regular expressions (re.findall()) Note that it's usually more efficient to just run the for-loop over the file object, rather than using readlines()

Re: extract substring by regex from a text file

2010-04-17 Thread Alessio
On Apr 15, 3:25 pm, Neil Cerutti wrote: > On 2010-04-15, Alessio wrote: > > > Hi, > > > I'm facing the problem in the subject: > > - I have a text file that I need to parse for producing a specifical Thank you, I forgot to say that I already solved. I used readli

Re: extract substring by regex from a text file

2010-04-15 Thread Neil Cerutti
On 2010-04-15, Alessio wrote: > Hi, > > I'm facing the problem in the subject: > - I have a text file that I need to parse for producing a specifical > string (Json like) extracting some information (substring) in it; > - I created regural expressions capable to locate t

extract substring by regex from a text file

2010-04-15 Thread Alessio
Hi, I'm facing the problem in the subject: - I have a text file that I need to parse for producing a specifical string (Json like) extracting some information (substring) in it; - I created regural expressions capable to locate these substrings in my txt file; now I don't know how t

Re: loop through each line in a text file

2010-03-01 Thread qtrimble
On Feb 26, 6:19 pm, ru...@yahoo.com wrote: > On Feb 26, 2:21 pm, qtrimble wrote: > > > > > On Feb 26, 4:14 pm, OdarR wrote: > > > > > > below is just a sample.  There are well over 500,000 lines that need > > > > processed. > > > > > wer1999001 > > > >       31.2234      82.2367 > > > >       37

Re: loop through each line in a text file

2010-02-26 Thread alex goretoy
I smell homework -- http://mail.python.org/mailman/listinfo/python-list

Re: loop through each line in a text file

2010-02-26 Thread rurpy
On Feb 26, 2:21 pm, qtrimble wrote: > On Feb 26, 4:14 pm, OdarR wrote: > > > > below is just a sample.  There are well over 500,000 lines that need > > > processed. > > > > wer1999001 > > >       31.2234      82.2367 > > >       37.9535      82.3456 > > > wer1999002 > > >       31.2234      82.2

Re: loop through each line in a text file

2010-02-26 Thread John Posner
On 2/26/2010 4:21 PM, qtrimble wrote: fileIN = open(r"C:\testing.txt", "r") for line in fileIN: year = line[3:7] day = line[7:10] print year, day This is good since i can get the year and day of year into a variable but I haven't gotten any further. That's an excellent start.

Re: loop through each line in a text file

2010-02-26 Thread qtrimble
On Feb 26, 4:14 pm, OdarR wrote: > On 26 fév, 22:08, qtrimble wrote: > > > > > I'm a python newbie but I do have some basic scripting experience.  I > > need to take the line starting with "wer" and extract the year and day > > of year from that string.  I want to be able to add the year and day

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