Power shell查看文件夹大小
PS D:\0work> Get-ChildItem |
Format-Table -AutoSize Mode, LastWriteTime, Name, @{ Label="Length"; alignment="Left"; Expression={ if($_.PSIsContainer -eq $True) {(New-Object -com Scripting.FileSystemObject).GetFolder( $_.FullName).Size} else {$_.Length} } };log文件过大,单独收集其中关键数据,例如Pxx
import re
def main():
input_file = "log.lammps"
output_file = "Pxx.data" ####
with open(input_file, "r") as f_in, open(output_file, "w") as f_out:
data_start = False
step_index = -1
pxx_index = -1
for line in f_in:
if "Step" in line and "Pxx" in line: #####
headers = line.strip().split()
step_index = headers.index("Step")
pxx_index = headers.index("Pxx")
data_start = True
continue
if data_start:
if line.strip() == "":
data_start = False
continue
if re.match(r'^\d', line.strip()):
values = line.strip().split()
step = values[step_index]
pxx = values[pxx_index]
f_out.write(f"{step} {pxx}\n")
if __name__ == "__main__":
main()
评论
发表评论