Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1928554
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:59:35+00:00 2026-05-17T06:59:35+00:00

i download many html store in os,now get their content ,and extract data what

  • 0

i download many html store in os,now get their content ,and extract data what i need to persistence to mysql,
i use the traditional load file one by one ,it’s not efficant cost nealy 8 mins.

any advice is welcome

g_fields=[
 'name',
 'price',
 'productid',
 'site',
 'link',
 'smallImage',
 'bigImage',
 'description',
 'createdOn',
 'modifiedOn',
 'size',
 'weight',
 'wrap',
 'material',
 'packagingCount',
 'stock',
 'location',
 'popularity',
 'inStock',
 'categories',
]   @cost_time
def batch_xml2csv():
    "批量将xml导入到一个csv文件中"
    delete(g_xml2csv_file)
    f=open(g_xml2csv_file,"a")
    import os.path
    import mmap
    for file in glob.glob(g_filter):
    print "读入%s"%file
    ff=open(file,"r+")
    size=os.path.getsize(file)
    data=mmap.mmap(ff.fileno(),size)
    s=pq(data.read(size))
    data.close()
    ff.close()
    #s=pq(open(file,"r").read())
    line=[]
    for field in g_fields:
        r=s("field[@name='%s']"%field).text()
        if r is None:
            line.append("\N")
        else:
            line.append('"%s"'%r.replace('"','\"'))
    f.write(",".join(line)+"\n")
    f.close()
    print "done!"

i tried mmap,it seems didn’t work well

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:59:35+00:00Added an answer on May 17, 2026 at 6:59 am

    If you’ve got 25,000 text files on disk, ‘you’re doing it wrong’. Depending on how you store them on disk, the slowness could literally be seeking on disk to find the files.

    If you’ve got 25,0000 of anything it’ll be faster if you put it in a database with an intelligent index — even if you make the index field the filename it’ll be faster.

    If you have multiple directories that descend N levels deep, a database would still be faster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.