Skip to content

Instantly share code, notes, and snippets.

@leetschau
Created October 31, 2018 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leetschau/a52cb25e9217a85ecbcc143df1e0d672 to your computer and use it in GitHub Desktop.
Save leetschau/a52cb25e9217a85ecbcc143df1e0d672 to your computer and use it in GitHub Desktop.
阳城子光伏数据提取脚本
#!/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
@leetschau
Copy link
Author

leetschau commented Nov 2, 2018

求出6月份所有组串中最大的前10个电流值:
csvgrep -c time -m 201706 ycz6502.csv| csvsort -c value -r | head

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment