Python Export Excel file

Source: Internet
Author: User

Based on previously exported to txt file paste stick crawler content

Example:

Title: Flower   "Wolf 2" to Dian    firstauthor: Lovely ... renum:6     Content: Focus   Bow weight  hao→ ziyuanhuoqu  back   battle Wolf 2   lastauthor: Shell-and-mold      lasttime:10:16 title:z Wolf 2    firstauthor:xin Summer micro-shadow      Renum:6    content: Just finished, the old actor acting is such a good  lastauthor: Luozi ID ...  lasttime:10:01  Title: Wolf 2 originally 140 minutes long, how   firstauthor: War Wolf Yong ...  renum:2    content: Wolf 2 was originally 140 minutes long, Why is it only 100 minutes now?   lastauthor: The Battle Wolf forever ...   lasttime:09:31 title: "Arcade holiday Catch Fishing" Hand Tour version   full screen bomb strength preferred   Firstauthor:    renum:4    content:rt lastauthor: The crown of the enemy      lasttime:7-10  title: Wolf 2 "not cut HD" h "full complete" Who wants   firstAuthor:xjz38269    renum:24   content: As an experienced person, advise you just stepping into the Society of Friends: in Work and life, to be honest, do things to Benbon, step by step, do not install p, less pat useless horse fart, learn more, Dare to challenge the boss and authority, adhere to do their own, live out of your own wonderful.   OnlyIn this way, you can watch others quickly rise to the road to success!     lastauthor: This snow ...   lasttime:7-10  title: the July 23 "Wolf 2" movie premiere will be 2 guests!  firstauthor:kevin three princess    renum:2    content: "Wolf 2"   officially released on July 28   Of course, large-format, big scene, big production (serious face)   Grand tribute to the 90 anniversary   Click  https://i   lastauthor: Keio  lasttime:7-10   title: Battle Wolf 2 live   firstauthor:kevin three Princess    reNum:0     Content: Wolves 2 only designated gift hands     lastauthor:kevin three Princess     lastTime:7-10   title: Spoiling Wolf   firstauthor: less t    renum:1    content: Spoiling Wolf     lastauthor:20323 Rui   lasttime:7-10 ...

Store such crawler content in Excel

#-*-Coding:utf-8-*-import XLWTBOOK=XLWT. Workbook (encoding= ' UTF8 ', style_compression=0) sheet=book.add_sheet (' Tieba ') with open (' Tieba.txt ', ' R ') as Fp:line=    Fp.readline () i=0;            While Line:lists=line.split (' \ t ') for Key,value in Enumerate (lists): Pos=value.find (': ') Sheet.write (i, Key, value[pos+1:]) line=fp.readline () i + = 1book.save (' D:\\tieba.xls ')

The Python XLWT module is used here to read the text line by row, insert it into Excel, and then export it successfully.

Python export Excel file

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.