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

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.com/chart/top;) var_html =

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

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") > >

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:41:19 PM UTC-5, ryguy7272 wrote: > On Wednesday, November 18, 2015 at 12:21:47 PM UTC-5, Denis McMahon wrote: > > On Wed, 18 Nov 2015 08:37:47 -0800, ryguy7272 wrote: > > > > > I'm trying the script below... > > > > The problem isn't that you're over-writing

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

2015-11-18 Thread Denis McMahon
On Wed, 18 Nov 2015 08:37:47 -0800, ryguy7272 wrote: > I'm trying the script below... The problem isn't that you're over-writing the lines (although it may seem that way 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

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:21:47 PM UTC-5, Denis McMahon wrote: > On Wed, 18 Nov 2015 08:37:47 -0800, ryguy7272 wrote: > > > I'm trying the script below... > > The problem isn't that you're over-writing the lines (although it may > seem that way to you), the problem is that you're

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 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 file, > everything is jumbled

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. --