I was given some usage statistics data. Its months of data split into multiple TSV files missing header;
07-01-2017_01.tsv
07-01-2017_02.tsv
07-02-2017_01.tsv
07-02-2017_02.tsv
07-03-2017_01.tsv
07-03-2017_02.tsv
07-04-2017_01.tsv
07-04-2017_02.tsv
07-04-2017_03.tsv
I would like to merge the data per day, add header and export it as CSV. I managed to do it with the following code for 1 day, but I was wondering if there is any way to automate it so that I would not need to run the code for each day of the month.
  data_part1 <-  read.delim("~/07-01-2017_01.tsv", header = FALSE, sep = "\t", quote = "", stringsAsFactors=FALSE)
  data_part2 <-  read.delim("~/07-01-2017_02.tsv", header = FALSE, sep = "\t", quote = "", stringsAsFactors=FALSE)
  data_merged <- rbind(data_part1, data_part2)
  names(data_merged) <-
    c(
      "post_visid_high",
      "post_visid_low",
      "quarterly_visitor",
      "visid_timestamp",
      "visid_type",
      "visit_keywords",
      "visit_num",
      "visit_page_num",
      "visit_ref_domain",
      "visit_ref_type",
      "visit_referrer",
      "visit_search_engine",
      "visit_start_page_url",
      "visit_start_pagename",
      "visit_start_time_gmt",
    )
  write.csv(data_merged, "~/07-01-2017_02.csv")
Expected Output
07-01-2017_merged.csv
07-02-2017_merged.csv
07-03-2017_merged.csv
07-04-2017_merged.csv
 
     
    