-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eace2c4
commit 0e6f5b1
Showing
8 changed files
with
106 additions
and
793 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- codeing = utf-8 -*- | ||
# @Time :2023/7/6 10:54 | ||
# @Author :xming | ||
# @Version :1.0 | ||
# @Descriptioon : | ||
# @Link : | ||
# @File : pandas给csv添加表头.py | ||
|
||
import pandas as pd | ||
|
||
# 读取 CSV 文件 | ||
layer_path= r"C:\Users\12074\Desktop\Case-11_layer.csv" | ||
df = pd.read_csv(layer_path, header=[0]) | ||
# 添加表头 df.columns 赋值一个列表,指定了表头的名称 | ||
df.columns = ['start', 'end', 'LayerODin1', 'LayerWtLbFt1', 'LayerODin2', 'LayerWtLbFt2', 'LayerODin3', 'LayerWtLbFt3'] | ||
|
||
# 将带有表头的 DataFrame 写入 CSV 文件 index=False 参数,避免写入索引列 | ||
df.to_csv('data_with_header.csv', index=False) | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- codeing = utf-8 -*- | ||
# @Time :2023/7/5 16:27 | ||
# @Author :xming | ||
# @Version :1.0 | ||
# @Descriptioon : | ||
# @Link : | ||
# @File : 删除文件内容.py | ||
def remove_lines_with_stop_char(file_path, stop_char): | ||
with open(file_path, 'r') as file: | ||
lines = file.readlines() | ||
|
||
output_lines = [] | ||
for line in lines: | ||
if stop_char in line: | ||
break | ||
output_lines.append(line) | ||
|
||
# 使用列表推导式过滤掉要移除的元素 | ||
result = [x for x in lines if x not in output_lines] | ||
result[0] = result[0].replace("~A ", "") | ||
print(result) | ||
|
||
result = ''.join(result) | ||
|
||
with open(file_path, 'w') as file: | ||
file.write(result) | ||
|
||
|
||
# 使用示例 | ||
file_path = r"C:\Users\12074\Desktop\Case-11_Raw_Data.las" | ||
stop_char = '~A Depth' | ||
|
||
remove_lines_with_stop_char(file_path, stop_char) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.