S SmartDocs
Chuỗi bài: AI for Chemistry python 26 dòng · Cập nhật 2024-03-20

area.py

AI for Chemistry/code/2025_COSMO/data/s-profiles-all/area_volume-org/area.py

import pandas as pd
import numpy as np
import csv
import glob


# csv_list = glob.glob(r"C:\Users\user\Desktop\COSMOSAC-master\COSMO\COSMO_all\s-profiles-all\s-profile_area\*.csv")
csv_list = glob.glob(r"C:\Users\user\Desktop\COSMOSAC-master\COSMO\COSMO_all\s-profiles-all\s-profile\*.csv")
print("共有%s個CSV檔"% len(csv_list))
print(csv_list)

# with open("s-profile-area_area.csv", 'w', newline='') as wf:
with open("s-profile_area.csv", 'w', newline='') as wf:
    new_writer = csv.writer(wf)
    new_writer.writerow(["CID","area"])
    for i in csv_list:
        if "-b3lyp.csv"==i[-10:]:                           #最後10個字相等(-b3lyp.csv)
            csvreader = csv.reader(open(i, "r"))
            for index, rows in enumerate(csvreader):
                if index == 51:                             #index == 51 (第52行)
                    ni ="".join([a for a in i[-22:-14] if a.isdigit()])   # 取各檔名(CID)最後面數過來第22個(最多)~最後面數過來第14個(至少) (54676228-opt-b3lyp.csv)
                    fileHeader = [ni, rows[1]]                            # 則取54676228 (舉例)
                    new_writer.writerow(fileHeader)

wf.close()

Bài viết liên quan

AI for Chemistry python Cập nhật 2023-11-13

cosmo_to_s_profile_ver_1.1.1.py

cosmo_to_s_profile_ver_1.1.1.py — python source code from the AI for Chemistry learning materials (AI for Chemistry/2025_COSMO/data/s-profiles-all/List-9/cosmo_to_s_profile_ver_1.1.1.py).

Đọc bài viết →
AI for Chemistry python Cập nhật 2024-03-20

area.py

area.py — python source code from the AI for Chemistry learning materials (AI for Chemistry/2025_COSMO/data/s-profiles-all/area_volume-org/area.py).

Đọc bài viết →
AI for Chemistry python Cập nhật 2024-06-27

area_volume.py

area_volume.py — python source code from the AI for Chemistry learning materials (AI for Chemistry/2025_COSMO/data/s-profiles-all/area_volume-org/area_volume.py).

Đọc bài viết →
AI for Chemistry python Cập nhật 2024-06-27

volume.py

volume.py — python source code from the AI for Chemistry learning materials (AI for Chemistry/2025_COSMO/data/s-profiles-all/area_volume-org/volume.py).

Đọc bài viết →
AI for Chemistry python Cập nhật 2024-04-26

check_final_CID.py

check_final_CID.py — python source code from the AI for Chemistry learning materials (AI for Chemistry/2025_COSMO/data/s-profiles-all/check/check_final_CID.py).

Đọc bài viết →
AI for Chemistry python Cập nhật 2024-03-20

check_for_CID.py

check_for_CID.py — python source code from the AI for Chemistry learning materials (AI for Chemistry/2025_COSMO/data/s-profiles-all/check/check_for_CID.py).

Đọc bài viết →