I'm trying to read some CSV-format financial tick data (source: HISTDATA_COM_ASCII_EURUSD_T_201209.zip) into a zoo series. The data is indexed by a time column which contains timestamps formatted such as 20120902 170010767
- almost like %Y%m%d %H%M%OS3
except milliseconds are not seperated by a decimal point as required by %OS3
.
I have attempted to force the required decimal point by dividing the latter (right) half of the timestamp by 1000 and pasting back together again:
FUN <- function(i, format) {
sapply(strsplit(i, " "), function(j) strptime(paste(j[1], as.numeric(j[2])/1000), format = format))
}
read.zoo(file, format = "%Y%m%d %H%M%OS3", FUN = FUN, sep = ",")
However, this has not worked - could someone please shed some light on how best to do this properly?
Many thanks