Re: open text file

2022-06-24 Thread jak
Il 24/06/2022 15:10, simone zambonardi ha scritto: Good morning, I need to read a text file. How come when I open it (running the script) it says this? The text file is type RFT {\rtf1\ansi\ansicpg1252\cocoartf2636 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica

Re: open text file

2022-06-24 Thread jak
Il 24/06/2022 15:44, jak ha scritto: Il 24/06/2022 15:10, simone zambonardi ha scritto: Good morning, I need to read a text file. How come when I open it (running the script) it says this? The text file is type RFT {\rtf1\ansi\ansicpg1252\cocoartf2636 \cocoatextscaling0\cocoaplatform0

Re: python Store text file in mangodb

2022-06-13 Thread Peter Otten
On 12/06/2022 14:40, Ayesha Tassaduq wrote: Hi i am trying to store a text file into MongoDB but i got the error . "failing because no such method exists." % self.__name.split(".")[-1] TypeError: 'Collection' object is not callable. If you meant to call the &#

python Store text file in mangodb

2022-06-12 Thread Ayesha Tassaduq
Hi i am trying to store a text file into MongoDB but i got the error . "failing because no such method exists." % self.__name.split(".")[-1] TypeError: 'Collection' object is not callable. If you meant to call the 'insert' method on a 'Collection

Re: Trying to read from a text file to generate a graph

2021-07-29 Thread Anssi Saari
"Steve" writes: > I am going though a struggle with this and just don't see where it fails. It seems to me you're putting your data into strings when you need to put it into lists. And no, adding brackets and commas to your strings so that printing out the strings makes them look like lists does

RE: Trying to read from a text file to generate a graph

2021-07-29 Thread Steve
17 bugs in the code. -Original Message- From: Python-list On Behalf Of Stephen Berman Sent: Wednesday, July 28, 2021 5:36 PM To: python-list@python.org Subject: Re: Trying to read from a text file to generate a graph [Resending to the list only, since I couldn't post it without su

Re: Trying to read from a text file to generate a graph

2021-07-28 Thread Stephen Berman
[Resending to the list only, since I couldn't post it without subscribing.] On Wed, 28 Jul 2021 11:58:21 -0400 "Steve" wrote: > I forgot about the no-file rule... > >> On 28Jul2021 02:55, Steve wrote: >> I am going though a struggle with this and just don't see where it >> fails. I am using th

RE: Trying to read from a text file to generate a graph

2021-07-28 Thread Steve
I forgot about the no-file rule... On 28Jul2021 02:55, Steve wrote: >I am going though a struggle with this and just don't see where it fails. >I am using the Dual Bar Graph.py program from https://matplotlib.org/stable/gallery/index.html website. >The file from the web site works so that shows t

Re: Trying to read from a text file to generate a graph

2021-07-28 Thread Cameron Simpson
On 28Jul2021 02:55, Steve wrote: >I am going though a struggle with this and just don't see where it fails. >I am using the Dual Bar Graph.py program from >https://matplotlib.org/stable/gallery/index.html website. >The file from the web site works so that shows that all my installations are >com

Trying to read from a text file to generate a graph

2021-07-28 Thread Steve
I am going though a struggle with this and just don't see where it fails. I am using the Dual Bar Graph.py program from https://matplotlib.org/stable/gallery/index.html website. The file from the web site works so that shows that all my installations are complete. My program, LibreGraphics 05.py

Re: How to loop over a text file (to remove tags and normalize) using Python

2021-03-10 Thread Dan Stromberg
t; #or # #lynx -force_html -dump "$@" # #or # #w3m -T text/html -F -dump "$@" On Tue, Mar 9, 2021 at 1:26 PM S Monzur wrote: > Dear List, > > Newbie here. I am trying to loop over a text file to remove html tags, > punctuation marks, stopwords. I have already used Beaut

Re: How to loop over a text file (to remove tags and normalize) using Python

2021-03-10 Thread Peter Otten
text file. https://pastebin.com/8BMi9qjW . I am now trying to remove the html tags from this text file, and running into issues as mentioned in the previous post. As I said in my previous post, when you process the list entries separately you will probably avoid the problem. Unfortunately with the

Re: How to loop over a text file (to remove tags and normalize) using Python

2021-03-10 Thread S Monzur
I initially scraped the links using beautiful soup, and from those links downloaded the specific content of the articles I was interested in (titles, dates, names of contributor, main texts) and stored that information in a list. I then saved the list to a text file. https://pastebin.com/8BMi9qjW

Re: How to loop over a text file (to remove tags and normalize) using Python

2021-03-10 Thread Peter Otten
On 10/03/2021 04:35, S Monzur wrote: Thanks! I ended up using beautiful soup to remove the html tags and create three lists (titles of article, publications dates, main body) but am still facing a problem where the list is not properly storing the main body. There is something wrong with my code

Re: How to loop over a text file (to remove tags and normalize) using Python

2021-03-10 Thread Joel Goldstick
On Tue, Mar 9, 2021 at 10:36 PM S Monzur wrote: > > Thanks! I ended up using beautiful soup to remove the html tags and create > three lists (titles of article, publications dates, main body) but am still > facing a problem where the list is not properly storing the main body. > There is something

Re: How to loop over a text file (to remove tags and normalize) using Python

2021-03-09 Thread S Monzur
e and bodytext. > > > >4. Remove punctuation and stopwords (I've used a user generated > function > > for that). > > > > I've been able to do all of these steps for the file > [2]ListFileReduced, > > as shown in the code (although it&#

Re: How to loop over a text file (to remove tags and normalize) using Python

2021-03-09 Thread Dan Ciprus (dciprus) via Python-list
). I've been able to do all of these steps for the file [2]ListFileReduced, as shown in the code (although it's clunky). But, I would like to be able to do it for the other text file: [3]ListFile which has more articles. I used BeautifulSoup to scrape the data from the website,

Re: How to loop over a text file (to remove tags and normalize) using Python

2021-03-09 Thread S Monzur
drive.google.com/file/d/1ojwN4u8cmh_nUoMJpdZ5ObaGW5URYYj3/view?usp=sharing>, as shown in the code (although it's clunky). But, I would like to be able to do it for the other text file: ListFile <https://drive.google.com/file/d/1V3s8w8a3NQvex91EdOhdC9rQtCAOElpm/view?usp=sharing> which has more article

Re: How to loop over a text file (to remove tags and normalize) using Python

2021-03-09 Thread Dan Ciprus (dciprus) via Python-list
If you could utilized pastebin or similar site to show your code, it would help tremendously since it's an unindented mess now and can not be read easily. On Wed, Mar 10, 2021 at 03:07:14AM +0600, S Monzur wrote: Dear List, Newbie here. I am trying to loop over a text file to remove html

How to loop over a text file (to remove tags and normalize) using Python

2021-03-09 Thread S Monzur
Dear List, Newbie here. I am trying to loop over a text file to remove html tags, punctuation marks, stopwords. I have already used Beautiful Soup (Python v 3.8.3) to scrape the text (newspaper articles) from the site. It returns a list that I saved as a file. However, I am not sure how to use a

Re: Python read text file columnwise

2019-01-15 Thread Neil Cerutti
On 2019-01-15, Juris __ wrote: > Hi! > > On 15/01/2019 17:04, Neil Cerutti wrote: >> On 2019-01-11, shibashib...@gmail.com wrote: >>> Hello I'm very new in python. I have a file in the format: 2018-05-31 16:00:0028.90 81.77 4.3 2018-05-31 20:32:002

Re: Python read text file columnwise

2019-01-15 Thread Juris __
Hi! On 15/01/2019 17:04, Neil Cerutti wrote: > On 2019-01-11, shibashib...@gmail.com wrote: >> Hello >>> >>> I'm very new in python. I have a file in the format: >>> >>> 2018-05-31 16:00:0028.90 81.77 4.3 >>> 2018-05-31 20:32:0028.17 84.89 4.1 >>> 2018-06-20 04:09:00

Re: Python read text file columnwise

2019-01-15 Thread Neil Cerutti
On 2019-01-11, shibashib...@gmail.com wrote: > Hello >> >> I'm very new in python. I have a file in the format: >> >> 2018-05-31 16:00:0028.90 81.77 4.3 >> 2018-05-31 20:32:0028.17 84.89 4.1 >> 2018-06-20 04:09:0027.36 88.01 4.8 >> 2018-06-20 04:15:00

RE: Python read text file columnwise

2019-01-14 Thread Schachner, Joseph
d returns the next value. Kind of useful when the alternative is making and passing around huge lists. --- Joseph S. -Original Message- From: DL Neil Sent: Saturday, January 12, 2019 4:48 PM To: python-list@python.org Subject: Re: Python read text file columnwise On 12/01/19 1:03 PM

RE: Python read text file columnwise

2019-01-12 Thread Avi Gross
-Original Message- From: Avi Gross Sent: Saturday, January 12, 2019 8:26 PM To: 'DL Neil' Subject: RE: Python read text file columnwise I am not sure what the big deal is here. If the data is consistently formatted you can read in a string per line and use offsets as i

Re: Python read text file columnwise

2019-01-12 Thread DL Neil
On 12/01/19 1:03 PM, Piet van Oostrum wrote: shibashib...@gmail.com writes: Hello I'm very new in python. I have a file in the format: 2018-05-31 16:00:0028.90 81.77 4.3 2018-05-31 20:32:0028.17 84.89 4.1 2018-06-20 04:09:0027.36 88.01 4.8 2

Silent data corruption in pandas, was Re: Python read text file columnwise

2019-01-12 Thread Peter Otten
Peter Otten wrote: > shibashib...@gmail.com wrote: > >> Hello >>> >>> I'm very new in python. I have a file in the format: >>> >>> 2018-05-31 16:00:0028.90 81.77 4.3 >>> 2018-05-31 20:32:0028.17 84.89 4.1 >>> 2018-06-20 04:09:0027.36 88.01 4.8 >>> 2018-06-

Re: Python read text file columnwise

2019-01-12 Thread Peter Otten
shibashib...@gmail.com wrote: > Hello >> >> I'm very new in python. I have a file in the format: >> >> 2018-05-31 16:00:0028.90 81.77 4.3 >> 2018-05-31 20:32:0028.17 84.89 4.1 >> 2018-06-20 04:09:0027.36 88.01 4.8 >> 2018-06-20 04:15:0027.31

Re: Python read text file columnwise

2019-01-11 Thread Cameron Simpson
On 11Jan2019 12:43, shibashib...@gmail.com wrote: I'm very new in python. I have a file in the format: 2018-05-31 16:00:0028.90 81.77 4.3 2018-05-31 20:32:0028.17 84.89 4.1 2018-06-20 04:09:0027.36 88.01 4.8 2018-06-20 04:15:0027.3

Re: Python read text file columnwise

2019-01-11 Thread Piet van Oostrum
shibashib...@gmail.com writes: > Hello >> >> I'm very new in python. I have a file in the format: >> >> 2018-05-31 16:00:0028.90 81.77 4.3 >> 2018-05-31 20:32:0028.17 84.89 4.1 >> 2018-06-20 04:09:0027.36 88.01 4.8 >> 2018-06-20 04:15:0027.31

Re: Python read text file columnwise

2019-01-11 Thread Rich Shepard
On Fri, 11 Jan 2019, shibashib...@gmail.com wrote: I'm very new in python. I have a file in the format: 2018-05-31 16:00:0028.90 81.77 4.3 2018-05-31 20:32:0028.17 84.89 4.1 2018-06-20 04:09:0027.36 88.01 4.8 2018-06-20 04:15:0027.

Re: Python read text file columnwise

2019-01-11 Thread shibashibani
Hello > > I'm very new in python. I have a file in the format: > > 2018-05-3116:00:0028.90 81.77 4.3 > 2018-05-3120:32:0028.17 84.89 4.1 > 2018-06-2004:09:0027.36 88.01 4.8 > 2018-06-2004:15:0027.31 87.09 4.7 > 2018-06-2804.07:00

Python read text file columnwise

2019-01-11 Thread shibashibani
Hello, I'm very new in python. I have a file in the format: 2018-05-31 16:00:0028.90 81.77 4.3 2018-05-31 20:32:0028.17 84.89 4.1 2018-06-20 04:09:0027.36 88.01 4.8 2018-06-20 04:15:0027.31 87.09 4.7 2018-06-28 04.07:00

Re: I try to edit and find data from a text file with python 2.7 (data from stock market)

2018-09-07 Thread Peter Otten
alon.naj...@gmail.com wrote: > hi, > > I try to edit a text file with python 2.7: > > * AAPL * > Date: September 07 2018 > Time: 14:10:52 > Price: ,068,407 > Ask: None > High: None > Low: None > Previous Close: ,068,407 > Volume: $ 227.35 / $ 22

I try to edit and find data from a text file with python 2.7 (data from stock market)

2018-09-07 Thread alon . najman
hi, I try to edit a text file with python 2.7: * AAPL * Date: September 07 2018 Time: 14:10:52 Price: ,068,407 Ask: None High: None Low: None Previous Close: ,068,407 Volume: $ 227.35 / $ 221.30 Market Cap: 20.23 but when I write it to a file I get: {'previous_close':

Re: program that search string in text file and do something

2017-08-06 Thread Rick Johnson
Grant Edwards wrote: > Peter Otten <__pete...@web.de> wrote: > > > What we won't do is write a program for you ready to > > present to your teacher. > > Or if we do, it will be subtly sabotaged in a manner that > will make it obvious to an experienced Python programmer > that you didn't write it.

Re: program that search string in text file and do something

2017-08-04 Thread Grant Edwards
On 2017-08-04, Peter Otten <__pete...@web.de> wrote: > What we won't do is write a program for you ready to present to your > teacher. Or if we do, it will be subtly sabotaged in a manner that will make it obvious to an experienced Python programmer that you didn't write it. My favorite is to u

Re: program that search string in text file and do something

2017-08-04 Thread ast
a écrit dans le message de news:f705c092-de18-4c37-bde1-42316e8de...@googlegroups.com... On Friday, August 4, 2017 at 12:27:02 PM UTC+3, ast wrote: a écrit dans le message de news:b6cc4ee5-71be-4550-be3e-59ebeee7a...@googlegroups.com... thanks man! that works I hope it is not a school h

Re: program that search string in text file and do something

2017-08-04 Thread alon . najman
ow to write a program that do: > > - search for a string in certain text file and if it founds the string it > > delete the file? and > > print something? > > > > thanks. > > import os > pattern = "azerty" > found = False > > with open("

Re: program that search string in text file and do something

2017-08-04 Thread Peter Otten
Peter Otten wrote: > What we won't do is write a program for you ready to present to your > teacher. I should have known better :( -- https://mail.python.org/mailman/listinfo/python-list

Re: program that search string in text file and do something

2017-08-04 Thread Peter Otten
alon.naj...@gmail.com wrote: > Hi, I'm new to thing forum and to this programming in python! > > can someone help me and write me how to write a program that do: > - search for a string in certain text file and if it founds the string it > delete the file? and print someth

Re: program that search string in text file and do something

2017-08-04 Thread ast
a écrit dans le message de news:b6cc4ee5-71be-4550-be3e-59ebeee7a...@googlegroups.com... Hi, I'm new to thing forum and to this programming in python! can someone help me and write me how to write a program that do: - search for a string in certain text file and if it founds the stri

program that search string in text file and do something

2017-08-04 Thread alon . najman
Hi, I'm new to thing forum and to this programming in python! can someone help me and write me how to write a program that do: - search for a string in certain text file and if it founds the string it delete the file? and print something? thanks. -- https://mail.python.org/mailman/lis

Re: Convert text file data into RDF format through the Python

2017-05-01 Thread Grant Edwards
On 2017-05-01, Peter Pearson wrote: > On Sat, 29 Apr 2017 10:06:12 -0700 (PDT), marsh > wrote: >> Hi, >> >> I would like to ask how can I convert text file data into RDF fromat. > [snip] > > What is RDF format? https://en.wikipedia.org/wiki/Resource_Descript

Re: Convert text file data into RDF format through the Python

2017-05-01 Thread Peter Pearson
On Sat, 29 Apr 2017 10:06:12 -0700 (PDT), marsh wrote: > Hi, > > I would like to ask how can I convert text file data into RDF fromat. [snip] What is RDF format? -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list

Convert text file data into RDF format through the Python

2017-04-29 Thread marsh
Hi, I would like to ask how can I convert text file data into RDF fromat. data look like this: # sent_id = weblog-juancole.com_juancole_20051126063000_ENG_20051126_063000-0001 # text = Al-Zaman : American forces killed Shaikh Abdullah al-Ani, the preacher at the mosque in the town of Qaim

Re: Reading structured text file (non-CSV) into Pandas Dataframe

2017-04-13 Thread breamoreboy
On Thursday, April 13, 2017 at 11:09:23 AM UTC+1, David Shi wrote: > http://www.ebi.ac.uk/ena/data/warehouse/search?query=%22geo_circ(-0.587,-90.5713,170)%22&result=sequence_release&display=text > The above is a web link to a structured text file.  It is not a CSV. > How can this

Reading structured text file (non-CSV) into Pandas Dataframe

2017-04-13 Thread David Shi via Python-list
http://www.ebi.ac.uk/ena/data/warehouse/search?query=%22geo_circ(-0.587,-90.5713,170)%22&result=sequence_release&display=text The above is a web link to a structured text file.  It is not a CSV. How can this text file be read into a Pandas Dataframe, so that further processing can

Re: Read a text file into a Pandas DataFrame Table

2017-04-13 Thread breamoreboy
On Thursday, April 13, 2017 at 9:15:18 AM UTC+1, David Shi wrote: > Dear All, > Can anyone help to read a text file into a Pandas DataFrame Table? > Please see the link below. > http://www.ebi.ac.uk/ena/data/warehouse/search?query=%22geo_circ(-0.587,-90.5713,170)%22&result=sequence

Read a text file into a Pandas DataFrame Table

2017-04-13 Thread David Shi via Python-list
Dear All, Can anyone help to read a text file into a Pandas DataFrame Table? Please see the link below. http://www.ebi.ac.uk/ena/data/warehouse/search?query=%22geo_circ(-0.587,-90.5713,170)%22&result=sequence_release&display=text Regards. David -- https://mail.python.org/mailman/listinf

Re: Python text file fetch specific part of line

2016-08-02 Thread honeygne
On Thursday, July 28, 2016 at 1:00:17 PM UTC+5:30, c...@zip.com.au wrote: > On 27Jul2016 22:12, Arshpreet Singh wrote: > >I am writing Imdb scrapper, and getting available list of titles from IMDB > >website which provide txt file in very raw format, Here is the one part of > >file(http://pasteb

Re: Python text file fetch specific part of line

2016-07-29 Thread cs
On 29Jul2016 18:42, Gordon Levi wrote: c...@zip.com.au wrote: On 28Jul2016 19:28, Gordon Levi wrote: Arshpreet Singh wrote: I am writing Imdb scrapper, and getting available list of titles from IMDB website which provide txt file in very raw format, Here is the one part of file(http://past

Re: Python text file fetch specific part of line

2016-07-29 Thread Gordon Levi
c...@zip.com.au wrote: >On 28Jul2016 19:28, Gordon Levi wrote: >>Arshpreet Singh wrote: >>>I am writing Imdb scrapper, and getting available list of titles from IMDB >>>website which provide txt file in very raw format, Here is the one part of >>>file(http://pastebin.com/fpMgBAjc) as the file

Re: Python text file fetch specific part of line

2016-07-28 Thread cs
On 28Jul2016 19:28, Gordon Levi wrote: Arshpreet Singh wrote: I am writing Imdb scrapper, and getting available list of titles from IMDB website which provide txt file in very raw format, Here is the one part of file(http://pastebin.com/fpMgBAjc) as the file provides tags like Distribution

Re: Python text file fetch specific part of line

2016-07-28 Thread Gordon Levi
Arshpreet Singh wrote: >I am writing Imdb scrapper, and getting available list of titles from IMDB >website which provide txt file in very raw format, Here is the one part of >file(http://pastebin.com/fpMgBAjc) as the file provides tags like Distribution > Votes,Rank,Title I want to parse titl

Re: Python text file fetch specific part of line

2016-07-28 Thread cs
On 27Jul2016 22:12, Arshpreet Singh wrote: I am writing Imdb scrapper, and getting available list of titles from IMDB website which provide txt file in very raw format, Here is the one part of file(http://pastebin.com/fpMgBAjc) as the file provides tags like Distribution Votes,Rank,Title I wa

Python text file fetch specific part of line

2016-07-27 Thread Arshpreet Singh
I am writing Imdb scrapper, and getting available list of titles from IMDB website which provide txt file in very raw format, Here is the one part of file(http://pastebin.com/fpMgBAjc) as the file provides tags like Distribution Votes,Rank,Title I want to parse title names, I tried with readlin

Re: fastest way to read a text file in to a numpy array

2016-06-30 Thread Christian Gollwitzer
Am 30.06.16 um 17:49 schrieb Heli: Dear all, After a few tests, I think I will need to correct a bit my question. I will give an example here. I have file 1 with 250 lines: X1,Y1,Z1 X2,Y2,Z2 Then I have file 2 with 3M lines: X1,Y1,Z1,value11,value12, value13, X2,Y2,Z2,value21,value22

Re: fastest way to read a text file in to a numpy array

2016-06-30 Thread Heli
Dear all, After a few tests, I think I will need to correct a bit my question. I will give an example here. I have file 1 with 250 lines: X1,Y1,Z1 X2,Y2,Z2 Then I have file 2 with 3M lines: X1,Y1,Z1,value11,value12, value13, X2,Y2,Z2,value21,value22, value23,... I will need to

Re: fastest way to read a text file in to a numpy array

2016-06-28 Thread Cody Piersall
On Tue, Jun 28, 2016 at 8:45 AM, Heli wrote: > Hi, > > I need to read a file in to a 2d numpy array containing many number of lines. > I was wondering what is the fastest way to do this? > > Is even reading the file in to numpy array the best method or there are > better approaches? > numpy.genf

Re: fastest way to read a text file in to a numpy array

2016-06-28 Thread Michael Selik
On Tue, Jun 28, 2016 at 10:08 AM Hedieh Ebrahimi wrote: > File 1 has : > x1,y1,z1 > x2,y2,z2 > > > and file2 has : > x1,y1,z1,value1 > x2,y2,z2,value2 > x3,y3,z3,value3 > ... > > I need to read the coordinates from file 1 and then interpolate a value > for these coordinates on file 2 to the

Re: fastest way to read a text file in to a numpy array

2016-06-28 Thread Michael Selik
On Tue, Jun 28, 2016 at 9:51 AM Heli wrote: > Is even reading the file in to numpy array the best method or there are > better approaches? > What are you trying to accomplish? Summary statistics, data transformation, analysis...? -- https://mail.python.org/mailman/listinfo/python-list

fastest way to read a text file in to a numpy array

2016-06-28 Thread Heli
Hi, I need to read a file in to a 2d numpy array containing many number of lines. I was wondering what is the fastest way to do this? Is even reading the file in to numpy array the best method or there are better approaches? Thanks for your suggestions, -- https://mail.python.org/mailman/li

Re: How can I export data from a website and write the contents to a text file?

2015-11-20 Thread Michael Torrie
On 11/19/2015 12:17 PM, Patrick Hess wrote: > ryguy7272 wrote: >> text_file = open("C:/Users/rshuell001/Desktop/excel/Text1.txt", "wb") >> [...] >> It doesn't seem like the '\n' is doing anything useful. All the text is >> jumbled together. >> [...] >> I finally got it working. It's like this: >

Re: How can I export data from a website and write the contents to a text file?

2015-11-19 Thread Patrick Hess
ryguy7272 wrote: > text_file = open("C:/Users/rshuell001/Desktop/excel/Text1.txt", "wb") > [...] > It doesn't seem like the '\n' is doing anything useful. All the text is > jumbled together. > [...] > I finally got it working. It's like this: > "\r\n" The better solution would be to open text f

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread Random832
ryguy7272 writes: > text_file = open("C:/Users/rshuell001/Desktop/excel/Text1.txt", "wb") Remove the "b" from this line. This is causing it to omit the platform-specific translation of "\n", which means some Windows applications will not recognize the line endings. -- https://mail.python.org/ma

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread Rob Gaddi
On Wed, 18 Nov 2015 09:40:58 -0800, ryguy7272 wrote: > > It doesn't seem like the '\n' is doing anything useful. All the text is > jumbled together. When I open the file in Excel, or Notepad++, it is > easy to read. However, when I open it in as a regular text fi

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread ryguy7272
, and you do so in file mode "wb" > > which restarts writing at the first byte of the file every time. > > > > You only need to open and close the text file once, instead of for every > > link you output. Try moving the lines to open and close the file out

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread ryguy7272
to you), the problem is that you're overwriting the whole > file every time you write a link to it. This is because you open and > close the file for every link you write, and you do so in file mode "wb" > which restarts writing at the first byte of the file every time. >

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread Denis McMahon
his is because you open and close the file for every link you write, and you do so in file mode "wb" which restarts writing at the first byte of the file every time. You only need to open and close the text file once, instead of for every link you output. Try moving the lines to ope

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread ryguy7272
On Wednesday, November 18, 2015 at 12:04:16 PM UTC-5, ryguy7272 wrote: > On Wednesday, November 18, 2015 at 11:58:17 AM UTC-5, Chris Angelico wrote: > > On Thu, Nov 19, 2015 at 3:37 AM, ryguy7272 <> wrote: > > > text_file = open("C:/Users/rshuell001/Desktop/excel/Text1.txt", > > > "wb") > >

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread ryguy7272
On Wednesday, November 18, 2015 at 11:58:17 AM UTC-5, Chris Angelico wrote: > On Thu, Nov 19, 2015 at 3:37 AM, ryguy7272 wrote: > > text_file = open("C:/Users/rshuell001/Desktop/excel/Text1.txt", "wb") > > z = str(link) > > text_file.write(z + "\n") > > text_file.writ

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 3:37 AM, ryguy7272 wrote: > text_file = open("C:/Users/rshuell001/Desktop/excel/Text1.txt", "wb") > z = str(link) > text_file.write(z + "\n") > text_file.write("\n") > text_file.close() You're opening the file every time you go through

How can I export data from a website and write the contents to a text file?

2015-11-18 Thread ryguy7272
I'm trying the script below, and it simple writes the last line to a text file. I want to add a '\n' after each line is written, so I don't overwrite all the lines. from bs4 import BeautifulSoup import urllib2 var_file = urllib2.urlopen("http://www.imdb.c

Re: Irregular last line in a text file, was Re: Regular expressions

2015-11-04 Thread Tim Chase
On 2015-11-04 14:39, Steven D'Aprano wrote: > On Wednesday 04 November 2015 03:56, Tim Chase wrote: >> Or even more valuable to me: >> >> with open(..., newline="strip") as f: >> assert all(not line.endswith(("\n", "\r")) for line in f) > > # Works only on Windows text files. > def chomp(li

Re: Irregular last line in a text file, was Re: Regular expressions

2015-11-04 Thread Oscar Benjamin
On 4 November 2015 at 03:39, Steven D'Aprano wrote: > > Better would be this: > > def chomp(lines): > for line in lines: > yield line.rstrip() # remove all trailing whitespace > > > with open(...) as f: > for line in chomp(f): ... with open(...) as f: for line in map(str.rstr

Re: Irregular last line in a text file, was Re: Regular expressions

2015-11-03 Thread Steven D'Aprano
On Wednesday 04 November 2015 03:56, Tim Chase wrote: > Or even more valuable to me: > > with open(..., newline="strip") as f: > assert all(not line.endswith(("\n", "\r")) for line in f) # Works only on Windows text files. def chomp(lines): for line in lines: yield line.rstrip(

Re: Irregular last line in a text file, was Re: Regular expressions

2015-11-03 Thread Grant Edwards
On 2015-11-03, Tim Chase wrote: [re. iterating over lines in a file] > I can't think of more than 1-2 times in my last 10+ years of > Pythoning that I've actually had potential use for the newlines, If you can think of 1-2 times when you've been interating over the lines in a file and wanted to

Re: Irregular last line in a text file, was Re: Regular expressions

2015-11-03 Thread Tim Chase
On 2015-11-03 11:39, Ian Kelly wrote: > >> because I have countless loops that look something like > >> > >> with open(...) as f: > >> for line in f: > >> line = line.rstrip('\r\n') > >> process(line) > > > > What would happen if you read a file opened like this without > > iter

Re: Irregular last line in a text file, was Re: Regular expressions

2015-11-03 Thread Ian Kelly
On Tue, Nov 3, 2015 at 11:33 AM, Ian Kelly wrote: > On Tue, Nov 3, 2015 at 9:56 AM, Tim Chase > wrote: >> Or even more valuable to me: >> >> with open(..., newline="strip") as f: >> assert all(not line.endswith(("\n", "\r")) for line in f) >> >> because I have countless loops that look som

Re: Irregular last line in a text file, was Re: Regular expressions

2015-11-03 Thread Ian Kelly
On Tue, Nov 3, 2015 at 9:56 AM, Tim Chase wrote: > On 2015-11-03 16:35, Peter Otten wrote: >> I wish there were a way to prohibit such files. Maybe a special >> value >> >> with open(..., newline="normalize") f: >> assert all(line.endswith("\n") for line in f) >> >> to ensure that all lines en

Re: Irregular last line in a text file, was Re: Regular expressions

2015-11-03 Thread Peter Otten
Tim Chase wrote: > On 2015-11-03 16:35, Peter Otten wrote: >> I wish there were a way to prohibit such files. Maybe a special >> value >> >> with open(..., newline="normalize") f: >> assert all(line.endswith("\n") for line in f) >> >> to ensure that all lines end with "\n"? > > Or even more

Re: Irregular last line in a text file, was Re: Regular expressions

2015-11-03 Thread Tim Chase
On 2015-11-03 16:35, Peter Otten wrote: > I wish there were a way to prohibit such files. Maybe a special > value > > with open(..., newline="normalize") f: > assert all(line.endswith("\n") for line in f) > > to ensure that all lines end with "\n"? Or even more valuable to me: with open(

Re: Irregular last line in a text file, was Re: Regular expressions

2015-11-03 Thread Jussi Piitulainen
Peter Otten writes: > Jussi Piitulainen wrote: >> Peter Otten writes: >> >>> If a "line" is defined as a string that ends with a newline >>> >>> def ends_in_asterisk(line): >>> return False >>> >>> would also satisfy the requirement. Lies, damned lies, and specs ;) >> >> Even if a "line" is d

Irregular last line in a text file, was Re: Regular expressions

2015-11-03 Thread Peter Otten
Jussi Piitulainen wrote: > Peter Otten writes: > >> If a "line" is defined as a string that ends with a newline >> >> def ends_in_asterisk(line): >> return False >> >> would also satisfy the requirement. Lies, damned lies, and specs ;) > > Even if a "line" is defined as a string that comes f

Re: Parsing data from text file to python

2015-08-09 Thread Laura Creighton
In a message of Mon, 10 Aug 2015 08:55:10 +0530, OmPs writes: >I have built a contact form which sends me email for every user >registration My question is more related to parsing some text data into csv >format. Your contact form should be able to produce csv files for you, rather than producing p

Parsing data from text file to python

2015-08-09 Thread OmPs
l for every user registration My question is more related to parsing some text data into csv format. and I have received multiple users information in my mail box which I had copied into a text file. The data looks like below. Name: testuser2 Email: testus...@gmail.com Cluster Name:

Re: What happens when python seeks a text file

2015-07-29 Thread Cameron Simpson
On 29Jul2015 07:52, dieter wrote: "=?GBK?B?wO68zsX0?=" writes: Hi, I tried using seek to reverse a text file after reading about the subject in the documentation: https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects https://docs.python.org/3/libra

Re: What happens when python seeks a text file

2015-07-28 Thread dieter
"=?GBK?B?wO68zsX0?=" writes: > Hi, I tried using seek to reverse a text file after reading about the > subject in the documentation: > > https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects > > https://docs.python.org/3/library/io.html#io.Tex

What happens when python seeks a text file

2015-07-28 Thread 李嘉鹏
Hi, I tried using seek to reverse a text file after reading about the subject in the documentation: https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects https://docs.python.org/3/library/io.html#io.TextIOBase.seek The script "reverse_text_by_seek3.py" produce

Re: Converting text file to different encoding.

2015-04-17 Thread Peter Otten
Chris Angelico wrote: > On Sat, Apr 18, 2015 at 12:26 AM, wrote: >> I tried to do as follows, > import codecs > sourceEncoding = "iso-8859-1" > targetEncoding = "utf-8" > source = open("source1","w") > string1="String type" > str1=str(string1) > source.write(str1) >>>

Re: Converting text file to different encoding.

2015-04-17 Thread Dave Angel
On 04/17/2015 10:48 AM, Dave Angel wrote: On 04/17/2015 09:19 AM, subhabrata.bane...@gmail.com wrote: >>> target = open("target", "w") It's not usually a good idea to use the same variable for both the file name and the opened file object. What if you need later to print the name, as in

Re: Converting text file to different encoding.

2015-04-17 Thread Marko Rauhamaa
Chris Angelico : > Here's how I'd do it. > > $ python3 with open("source1", encoding="iso-8859-1") as source, >> open("target", "w", encoding="utf-8") as target: > ... target.write(source.read()) You might run out of memory. How about: ===

Re: Converting text file to different encoding.

2015-04-17 Thread Dave Angel
(at least twice) at one time. This will also help enormously if you encounter any errors, and want to report the location and problem to the user. It might even turn out to be faster. You should write non-trivial code in a text file, and run it from there. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list

Re: Converting text file to different encoding.

2015-04-17 Thread Chris Angelico
On Sat, Apr 18, 2015 at 12:26 AM, wrote: > I tried to do as follows, import codecs sourceEncoding = "iso-8859-1" targetEncoding = "utf-8" source = open("source1","w") string1="String type" str1=str(string1) source.write(str1) source.close() target = op

Re: Converting text file to different encoding.

2015-04-17 Thread subhabrata . banerji
On Friday, April 17, 2015 at 7:36:46 PM UTC+5:30, Oscar Benjamin wrote: > wrote: > > On Friday, April 17, 2015 at 6:50:08 PM UTC+5:30, wrote: > >> I am having few files in default encoding. I wanted to change their > >> encodings, > >> preferably in "UTF-8", or may be from one encoding to any ot

Re: Converting text file to different encoding.

2015-04-17 Thread Oscar Benjamin
On 17 April 2015 at 14:51, wrote: > On Friday, April 17, 2015 at 6:50:08 PM UTC+5:30, subhabrat...@gmail.com > wrote: >> I am having few files in default encoding. I wanted to change their >> encodings, >> preferably in "UTF-8", or may be from one encoding to any other encoding. >> >> I was try

Re: Converting text file to different encoding.

2015-04-17 Thread subhabrata . banerji
On Friday, April 17, 2015 at 6:50:08 PM UTC+5:30, subhabrat...@gmail.com wrote: > I am having few files in default encoding. I wanted to change their > encodings, > preferably in "UTF-8", or may be from one encoding to any other encoding. > > I was trying it as follows, > >>>> import codec

Re: Converting text file to different encoding.

2015-04-17 Thread Rustom Mody
On Friday, April 17, 2015 at 6:50:08 PM UTC+5:30, subhabrat...@gmail.com wrote: > I am having few files in default encoding. I wanted to change their > encodings, > preferably in "UTF-8", or may be from one encoding to any other encoding. > > I was trying it as follows, > >>>> import codec

Converting text file to different encoding.

2015-04-17 Thread subhabrata . banerji
I am having few files in default encoding. I wanted to change their encodings, preferably in "UTF-8", or may be from one encoding to any other encoding. I was trying it as follows, >>> import codecs >>> sourceEncoding = "iso-8859-1" >>> targetEncoding = "utf-8" >>> source = open("so

  1   2   3   4   5   6   7   8   9   10   >