I'm analyzing large time series data files (hourly data), and compare them to each other on Unix To do. It would be easy if the same line is the same date and time in each file, however, some files are missing in some files, which makes the lines of different files do not match temporarily, so what I would like to do, In my data file, scanning dates and adding one hour is to include a line. The following example will help you understand:
This is the raw file:
5/3/03/11: 00 am, 2.62, 30.11 5/3 / 03, 12: 00PM, 2.63, 31.92 5/3/3,1: 00PM 2.6, 37.0 9 5/3/3,3: 00PM, 2.54, 36.46 < P> See that there is no data to disappear in 2PM on 5/3/03, so what I would like to do is to add a line with only the date to get it: 5 / 3 / 03,11: 00am, 2.62, 30.11 5/3/03/12: 00PM, 2.63, 31.92 5/3/3,1: 00PM, 2.6, 37.0 9 5/3/3, 2: 00pm 5/3/3,3: 00pm, 2.54, 36.46 I'm new to Unix and do not just see the way to do it. If you can brighten me then it will be very helpful!
Thank you in advance, Alice
Given a date, Kind of the next expected date can be found:
cdate = $ (echo "5/3/03/11: 00 am, 2.62, 30.11" | cut-d, -f1, 2) file from # ndate = $ (date + "% m /% d /% y,% I:% M% p" -d "$ {cdate /, / 1 hour"}) So, after a line is read, if the last ndate cdate is not equal, type ndate in a loop When they meet, type the line of the GNU date A bash script:
# and abuse! / Bin / bash ndate = "" read the line; Cdet = $ (echo $ line | cut-d, -f1,2) # from file #echo $ cdate $ ndate if [["$ ndate" == "" || "$ Ndate" == "$ cdate"]]; Then $ [$$ ndate! = $ Cdate]]; And echo the second line; Is "$ ndate ,,," ndate = $ (date + "% -m /% -d /% y,% - I:% M% p" -d "$ {ndate /, /} +1 hour") Done $ line FITT = $ (date + "% -m /% -d /% y,% - I:% M% p" -d "$ {cdate /, / 1 hour +1"; input
No comments:
Post a Comment