0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【R】接続

Posted at

library(readr)
library(XML)
library(stringr)

xmlToDataFrame("text.xml")

xml<-read_csv("text.xml",col_names =FALSE)
colnames(xml)<-("xml")

vin<-xml[grep("VIN",xml$xml),]

file_txt<-read_csv("filelist.txt",col_names = FALSE)
colnames(file_txt)<-("file_list")

list<-file_txt$file_list

for (tar_txt in list) {
xml<-read_csv(tar_txt,col_names =FALSE)
colnames(xml)<-("xml")
vn<-xml[grep("vn",xml$xml),]
print(vn)
}

file_list<-dir("./data/")
for (tar_txt in file_list) {
xml<-read_csv(tar_txt,col_names =FALSE)
colnames(xml)<-("xml")
vn<-xml[grep("vn",xml$xml),]

文字列抽出

pick_vn<-str_sub(vn,start = 6,end = -7)

data.frame(pick_vn,pick_system,pick_dtc,file_path)

}

###############wt#####
library(readr)

file_list<-dir("./wt_data")
setwd("./wt_data/")

wt_table<-data.frame()
col_list<-c("flag","CL_NUM","CL_NUM_H","CL_NUM_RO","PRO_CD","DATA_CD","WR_CD","RO_CD","Cont_CD","RO_CD_3","RO_CD_O","Cont_CD_O","ST_CD","DL_CD","PRO_div_CD","PRO_CD_D","MK_CD","CA_CD","PUR_CD","SIT_CD","DIS_CD_R","UNI_KEY","UNI_KEY_ORI","NU_CD","FR_CD","FR_NUM","MO_CD","MO_NAME","SER_CD","REG_DAY","WO_DAY","DISTA_CD","KM_DATA","MI_DATA","HOU_DATS","PA_DIST_CD","PAR_DIST_KM","PAR_DIST_MI","PAR_DIST_HO","BRA_CD","COS_CDS","CLA_DIST_CD","CH_DATE_RO","CH_DATE_H","BAN_DATE","ACC_DATE","ACCO_DATE","SS_DIST","WT_CD_RO","WT_CD_RO_RPA","WT_CD_RO_PA","WT_CD_BASE","RAT_WO","ARR_CO","CRE_DE_CD","MAK_R","PN_5","PN_3_1","PN_3_2","PN_EX","ALL_PN","CATE_CD","WT_CD_PA","PA_ER_CD","REP_REG_DATE","REP_DO_DATE","CONT_CD","SY_CD_1","SY_CD_2","PU_R_CD","TR_CD","QI_CD","DIST_SE_CD","DIST_SE_CD_RA","DAYS","PAR_COU_NUM","PAR_RA_CD","SUM_F","MY_CD","FA_CD","WR_CD_MA","ORI_DATE_CD","ORI_M_CD","EV_CD")
pick_col<-c("UNI_KEY")
for (wt_txt in file_list) {
wt<-read_csv(wt_txt,col_names =FALSE)
colnames(wt)<-(col_list)
pick_wt<-wt[,pick_col]
wt_table<-rbind(wt_table,pick_wt)

}
tmp<-read_csv("../list.txt",col_names = FALSE)
fix<-read_csv("../fix.txt",col_names=FALSE)
new_txt<-cbind(fix,tmp)
write.csv(new_txt,"../new.csv")

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?