Created
October 31, 2018 13:55
-
-
Save leetschau/a52cb25e9217a85ecbcc143df1e0d672 to your computer and use it in GitHub Desktop.
阳城子光伏数据提取脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 使用方法: | |
# * 提取文件 `ycz6502.csv` 中所有包含的日期,保存到各自的csv文件中:`./filecutter.sh ycz6502.csv` | |
# * 提取文件 `ycz6502.csv` 中指定日期(2017年6月4日)的数据到csv文件中:./filecutter.sh ycz6502.csv 20170604 | |
sourcefile=$(basename -s .csv $1) | |
if [[ $# -gt 1 ]]; then | |
csvgrep -c time -m $2 $1 > $sourcefile-$2.csv | |
echo "$sourcefile-$2.csv created" | |
exit 0 | |
fi | |
dates=$(sed 1d $1 | csvcut -d ' ' -c 1 | sort | uniq) | |
for day in $dates; do | |
csvgrep -c time -m $day $1 > $sourcefile-$day.csv | |
echo "$sourcefile-$day.csv created" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
求出6月份所有组串中最大的前10个电流值:
csvgrep -c time -m 201706 ycz6502.csv| csvsort -c value -r | head