ARTICLE DETAIL

资讯详情

深耕网站视觉设计与运营推广的一线实战洞察。

自用-提取红外相机相关的关键信息

自用-提取红外相机相关的关键信息 例如7050_IMAG0014_S10_N01 位置为CSV文件的第五列提取编码SXX和NXXlibrary(readr)library(stringr)library(dplyr)# CSV文件路径input_file - C:/Users/HUAWEI/Desktop/我的论文/红外相机文件信息汇总.csvoutput_file - E:/开题中期毕业文件/红外相机数据/第一批.csv# 读取含中文的CSVdata - read_csv(input_file,locale locale(encoding GB18030),show_col_types FALSE)# 获取第5列名称column_5 - names(data)[5]# S01-S500或者STR、ENDspecies_pattern - paste0((?i)(?![A-Za-z0-9]),(?:S(?:0[1-9]|[1-9][0-9]?|[1-4][0-9]{2}|500)|STR|END),(?![A-Za-z0-9]))# N01-N100number_pattern - paste0((?i)(?![A-Za-z0-9]),N(?:0[1-9]|[1-9][0-9]?|100),(?![A-Za-z0-9]))# 提取信息result - data %%mutate(物种 str_to_upper(str_extract(as.character(.data[[column_5]]),species_pattern)),数量 str_to_upper(str_extract(as.character(.data[[column_5]]),number_pattern)))write_excel_csv(result,output_file,na )cat(处理完成, output_file, \n)
返回列表