Hongmu Notes
Home Language Notes Python organizes data shared in batches on Baidu Netdisk
Language Notes python

Python organizes data shared in batches on Baidu Netdisk

Python organizes data shared in batches on Baidu Netdisk
import pandas as pd
import re
import os

# ---------- 输入输出路径 ----------
csv_path = r"C:\Users\18102\Downloads\jietu\百度网盘分享.csv"
output_excel = r"C:\Users\18102\Downloads\jietu\百度网盘分享完整.xlsx"

# ---------- 您新提供的三条分享记录 ----------
new_records = []

# ---------- 读取现有 CSV(如果存在) ----------
if os.path.exists(csv_path):
    try:
        df_existing = pd.read_csv(csv_path, encoding='utf-8')
    except UnicodeDecodeError:
        df_existing = pd.read_csv(csv_path, encoding='gbk')
    except Exception as e:
        print(f"读取CSV失败:{e}")
        exit()
    # 确保列名正确(若列数正好是4则重命名)
    expected_cols = ['文件名', '链接', '提取码', '分享状态']
    if list(df_existing.columns) != expected_cols:
        if len(df_existing.columns) == 4:
            df_existing.columns = expected_cols
        else:
            print("现有CSV列名不匹配,请检查。")
            print("当前列名:", df_existing.columns.tolist())
            exit()
else:
    print("CSV文件不存在,将只使用新添加的三条记录。")
    df_existing = pd.DataFrame(columns=['文件名', '链接', '提取码', '分享状态'])

# ---------- 添加新记录并去重(防止重复) ----------
df_new = pd.DataFrame(new_records)
df_combined = pd.concat([df_existing, df_new], ignore_index=True)
df_combined.drop_duplicates(subset=['文件名'], keep='first', inplace=True)

# ---------- 提取站点 ID ----------
def extract_id(filename):
    if not isinstance(filename, str):
        return None
    match = re.match(r'^(\d+)', filename)
    return int(match.group(1)) if match else None

df_combined['站点id'] = df_combined['文件名'].apply(extract_id)
# 过滤掉未提取到ID的行(正常情况下不会)
df_valid = df_combined[df_combined['站点id'].notna()].copy()

# ---------- 选择最终列,并按ID排序 ----------
df_result = df_valid[['站点id', '文件名', '链接', '提取码']].copy()
df_result.sort_values('站点id', ascending=True, inplace=True)

# ---------- 输出到 Excel ----------
df_result.to_excel(output_excel, index=False, engine='openpyxl')

print(f"✅ 完整Excel已生成,共 {len(df_result)} 条分享记录。")
print(f" 输出路径:{output_excel}")

 

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Import " requests" could not be resolved from source

Import " requests" could not be resolved from source Language Notes python

This error occurred when using Pylance, a Python language server. Among them, " Import " requests" could not be resolved from source" This error message indicates that the requests module is referenced in your code, but Pylance cannot find the location of the module from the source. The possible reason is that you don't have an …
👁 1771
Reinstall Python and requests libraries

Reinstall Python and requests libraries Language Notes python

If you meet " Import " requests" could not be resolved from source" You can try reinstalling Python and requests libraries. First, you need to uninstall the current Python and requests libraries. On Windows systems, you can use the command prompt …
👁 439
WARNING: Skipping requests as it is not installed.

WARNING: Skipping requests as it is not installed. Language Notes python

This error message indicates that your Python environment lacks the requests library, and this library is called in your code, so Python cannot execute your code normally. The solution to this problem is to install the requests library. You can use the pip command on the command line to install: pip install requests If you are using Python3, you can use the pip3 command …
👁 2100
Python reported an error. What is the reason? AttributeError: partially initialized module ' openai'  has no attribute ' Completion' (most likely due to a circular import)

Python reported an error. What is the reason? AttributeError: partially initialized module ' openai' has no attribute ' Completion' (most likely due to a circular import) Language Notes python

This error prompt indicates that there is a problem when importing the openai module and the specific Completion attribute, which is probably caused by circular import. The reason for this error may be that two or more modules in your code are imported from each other, forming a circular dependency. For example, module A imports module B, and module B imports module A.. Cyclic import will cause the module not to initialize correctly when loading, thus …
👁 656
How does python package and run on Windows?

How does python package and run on Windows? Language Notes python

The most common way to package and run Python programs on Windows is to use PyInstaller. PyInstaller is a free and cross-platform Python application packaging tool, which can package Python code and its dependent libraries into an independent executable file, making it possible to run Python programs on systems without Python interpreters installed. The following is to make …
👁 300
What programming software is good for python development?

What programming software is good for python development? Language Notes python

There are many programming softwares developed by Python. The following are some commonly used Python integrated development environments (IDE) and editors: PyCharmPyCharm is an integrated development environment developed by JetBrains, which is specially designed for Python developers. PyCharm is powerful and provides a series of advanced functions such as code completion, debugging, version control, code refactoring, etc., which can help developers improve their work …
👁 175

Recommended reading

Responsive electrical appliance instruction manual website template 0773

Responsive electrical appliance instruction manual website template 0773 Practical Collection Yiyou template

An eyoucms responsive website template for electrical appliance instruction manuals. The design style is simple and practical, and can display the instruction manuals, operation guides, FAQs and user manuals of electrical products. It helps home appliance brands provide product support services online. Template display Installation instructions Website backend: /login.php Account: admin Password: admin Related articles Yiyou CMS installation FAQ summary Yiyou CMS...
👁 55
(Adaptive Mobile Version) Responsive Education and Training Organization Website – PBootCMS Template; Download a professional education and training institution website source code – 0566

(Adaptive Mobile Version) Responsive Education and Training Organization Website – PBootCMS Template; Download a professional education and training institution website source code – 0566 Practical Collection pbootcms Template

A responsive PbootCMS website template designed for educational training groups and large-scale educational institutions, supporting mobile access. Its sophisticated and professional design makes it ideal for large educational organizations to showcase their curriculum offerings, faculty resources, and campus environments. This template helps educational groups build a strong online brand presence and attract prospective students. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www....
👁 35
PHP remotely obtains the .sql.zip file and then imports it into the database

PHP remotely obtains the .sql.zip file and then imports it into the database Language Notes PHP PHP and mysql

I have published a similar article before "PHP obtains the remote .sql.zip file, then clears the data, and then imports the .sql.zip into the mysql database", but here is another function that is also available for personal testing! 🔒 Hidden content: members can view /** * Download the ZIP compressed file containing the SQL file from the remote URL, decompress the SQL file to the specified directory, and then import the data to M…
👁 214
Responsive New Energy Chemical Research Institute website template 0415

Responsive New Energy Chemical Research Institute website template 0415 Practical Collection Yiyou template

An eyoucms responsive website template for the New Energy and Chemical Industry Research Institute. The design style is technological and environmentally friendly, and can showcase new energy projects, chemical research, technical achievements and institutional strength. It helps scientific research institutes establish an authoritative image online and attract cooperative customers. Template display Installation instructions Website backend: /login.php Account: admin Password: admin Related articles Yiyou CMS installation FAQ summary Yiyou...
👁 58
(Adaptive Mobile Version) pbootCMS Marketing-Oriented Industrial Bearing Enterprise Website Template – Responsive Hardware and Machinery Enterprise Website Source Code Download: 0226

(Adaptive Mobile Version) pbootCMS Marketing-Oriented Industrial Bearing Enterprise Website Template – Responsive Hardware and Machinery Enterprise Website Source Code Download: 0226 Practical Collection pbootcms Template

An adaptive mobile terminal PbootCMS marketing mechanical bearings and hardware mechanical equipment enterprise website template. Design style of professional atmosphere, pay attention to product display and brand tone. It is helpful for machinery manufacturing enterprises to display their product series online and obtain accurate customer inquiries. Template display, installation instructions website background: / admin.php account: admin password: admin decompression password: www.4s5.cn related articles...
👁 35
Responsive construction machinery and equipment enterprise website template 0072

Responsive construction machinery and equipment enterprise website template 0072 Practical Collection Yiyou template

This set of eyoucms responsive templates is suitable for construction machinery and equipment companies. The design style is professional and tough, and can display construction machinery products, construction cases and technical parameters. It helps construction machinery companies display their products online and attract construction and mining customers. Template display Installation instructions Website backend: /login.php Account: admin Password: admin Related articles Yiyou CMS installation FAQ summary Yiyou CMS (…
👁 41