Untitled
unknown
plain_text
3 years ago
691 B
15
Indexable
# Imposta il percorso del file CSV
file_path <- "/home/hadoop/Luca/ordini.csv"
# Legge il contenuto del file
file_content <- readLines(file_path)
year_month_doc=NULL
prices=NULL
# Itera sulle righe del file
print(length(seq_along(file_content)))
for (i in seq_along(file_content)) {
if(grepl("FATTURA", file_content[i])){
splitted_r = unlist(strsplit(file_content[i], ","))
#print(as.character(str_sub(ymd(splitted_r[2]),1,7)))
year_month = as.character(str_sub(ymd(splitted_r[2]),1,7))
price = splitted_r[3]
year_month_str = paste0(year_month," " ,splitted_r[1])
year_month_doc = rbind(year_month_doc, year_month_str)
prices = rbind(prices, price)
}
}Editor is loading...