|
@@ -102,11 +102,27 @@ def extract_column_data(df: pd.DataFrame, column_identifier: Union[str, int], st
|
|
|
logger.error(f"提取列数据时出错: {e}")
|
|
logger.error(f"提取列数据时出错: {e}")
|
|
|
raise
|
|
raise
|
|
|
|
|
|
|
|
-def test_column_extraction():
|
|
|
|
|
- output_dir = Path('temp')
|
|
|
|
|
- input_file = output_dir/"测试.csv"
|
|
|
|
|
- output_file = output_dir/"processed_测试.csv"
|
|
|
|
|
-
|
|
|
|
|
|
|
+def test_column_extraction(input_file: str):
|
|
|
|
|
+ """测试列提取功能
|
|
|
|
|
+
|
|
|
|
|
+ Args:
|
|
|
|
|
+ input_file: 输入CSV文件路径
|
|
|
|
|
+ """
|
|
|
|
|
+ try:
|
|
|
|
|
+ # 读取CSV文件
|
|
|
|
|
+ df = read_csv_with_header(input_file, header_row=1)
|
|
|
|
|
+
|
|
|
|
|
+ # 提取第二列的数据,从第三行开始
|
|
|
|
|
+ column_data = extract_column_data(df, column_identifier=1, start_row=2, header_row=1)
|
|
|
|
|
+
|
|
|
|
|
+ # 打印提取的数据
|
|
|
|
|
+ print("提取的列数据:")
|
|
|
|
|
+ print(column_data)
|
|
|
|
|
+
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ logger.error(f"测试列提取时出错: {e}")
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
- test_column_extraction()
|
|
|
|
|
|
|
+ output_dir = Path('temp')
|
|
|
|
|
+ input_file = output_dir / "测试.csv"
|
|
|
|
|
+ test_column_extraction(str(input_file))
|