在网络抓取之后和保存之前注释 CSV

Annotate CSV after web-scraping and before saving

我正在从网站的多个 URL 中抓取大量 html table 并将它们存储到单独的 csv 文件中。抓取完成后,我将所有 csv 文件合并为一个文件。因此,我想对每个 table 进行单独标识。

所以,我想知道是否有机会 annotate/add 将额外的输入(例如 "table1")输入到 CSV 文件的单元格 A1 中,或者自动将另一列添加到 csv 文件中在 K1:K12.

列中输入类似 "table1" 的文本
library(rvest)
url <- "URL of website" 
page <- read_html(url)
table <- html_table(page, fill = TRUE)
write.csv2(table, "table.csv")

提前致谢!

在将 ID 列保存到 csv 之前将其添加到 table

library(rvest)
url <- "URL of website" 
page <- read_html(url)
table <- html_table(page, fill = TRUE)
table <- cbind(id="table1", table)
write.csv2(table, "table.csv")