CAUTION!
Perl list
The input file format is as below.
[[2016-01-01,111]
- Contents comes as a single line.
- Remove 2 brackets at the beginning and the end of the line.
- Disassemble the line at "]
[", thus each entry contains the pair of data and its date., eachDissasseble entries at ",". Do this from the first entry to the last.- Save the date of the first entry.
- Concatenate retrieved data with ",". Thus construct the sequence which
start with the dataof the first date till the last date. - Use the date of the first entry and the last entry to create the necessary date sequence such as "seq(as.Date(\"start_date\"),as.Date(\"end_date\"),1)"
#! /
# $file="
$file="
$outfile="
# data is expected to come in a
# remove 2 brackets at the start and the end of the input.
$buff =
$buff =
# print $buff; # for debug only
# split data at the sequence of "]
@data = split(/\],\[/, $buff);
}
# get the length of the list.
$size = @data;
$count = 0;
# continue
# prepare start of the output statement.
$output = "w <- c
# break up the element by comma.
@xts = split
# for the first element of the list.
# save
$startdate = $xts
}
# concatenate incident number with comma.
$output =$output
$count++;
}
# remove comma at the end of $output
$output =
# add date sequence with start date and end date.
$output = $output."),seq(as.Date(\"$startdate\"),as.Date(\"$xts[0]\"),1)))";
$len = scalar
# remove input file.
0 件のコメント:
コメントを投稿