Commit 14a31efa authored by fengyuncheng's avatar fengyuncheng

v1

parent 20a5d840
This diff is collapsed.
采集器数据转换压缩
`./data/`一级文件夹下所有以`.tar.gz`结尾的压缩文件解压并压缩至csv文件中
header在`./tools/node/data.js`中,还有一个额外的Key:`time`,采用timestamp存储并去掉了毫秒信息
压缩后的csv文件将存放在`./output`,按照`td_mctd/meter_sn/td_mctd@meter_sn@yyyyMM.csv.bz2`的格式存放,存放一个采集器的一整个月的数据
\ No newline at end of file
......@@ -12,6 +12,7 @@ import com.hgny.protobuf.test3.AddressBook3;
import com.hgny.protobuf.test3.Person3;
import com.hgny.protobuf.utils.Constant;
import com.hgny.protobuf.utils.Tools;
import org.apache.commons.compress.utils.IOUtils;
import javax.tools.Tool;
import java.io.*;
......@@ -42,6 +43,9 @@ public class Main {
continue;
}
String gzName = gz.getName();
if (!gzName.contains(".tar.gz")) {
continue;
}
System.out.println("parse: " + gzName);
String folderName = Tools.extraTarGz(gz, "./data");
// 遍历目录解压tar.bz2
......@@ -56,8 +60,8 @@ public class Main {
int index = gzName.indexOf(".");
String fName = folderName.substring(0, index);
deleteFolder(new File("./data/" + fName));
Tools.compressTarGz("./output/" + fName, new File("./output/" + fName + ".tar.gz"));
deleteFolder(new File("./output/" + fName));
// Tools.compressTarGz("./output/" + fName, new File("./output/" + fName + ".tar.gz"));
// deleteFolder(new File("./output/" + fName));
System.out.println("spend: " + (System.currentTimeMillis() - start) + "ms");
start = System.currentTimeMillis();
}
......@@ -137,7 +141,7 @@ public class Main {
String s2 = s1.substring(0, index);
String month = s1.substring(index + 1);
String fileName = s2.replaceAll("/", "@") + month;
File file = new File(savePath + "/" + fileName + ".bz2");
File file = new File(savePath + "/" + fileName + ".csv.bz2");
String s = group.stream().map(list -> String.join("\n", list)).collect(Collectors.joining("\n"));
Tools.compressBZip2(s, file);
} else if (level == 4) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment