public static List<List<List<Object>>> getTodayData() throws Exception {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
List<List<Object>> data = getTestData();
List<List<List<Object>>> tables =
new ArrayList<>(data.stream().collect(Collectors.groupingBy(row -> row.get(0))).values());
tables.sort(Comparator.comparing(a -> ((java.sql.Timestamp) a.get(0).get(0))));
for (List<List<Object>> table : tables) {
table.sort(
Comparator.comparingDouble((List<Object> r) -> (double) r.get(8))
.thenComparing(r -> (String) r.get(2)));
}
for (List<List<Object>> table : tables) {
table.add(
Stream.concat(
Stream.of(table.get(0).get(0), "sum", "---"),
IntStream.range(3, 10)
.mapToObj(i -> table.stream().mapToDouble(r -> (double) r.get(i)).sum()))
.collect(Collectors.toCollection(ArrayList::new)));
}
for (List<List<Object>> table : tables) {
for (List<Object> row : table) {
row.set(0, df.format(new Date(((java.sql.Timestamp) row.get(0)).getTime())));
IntStream.range(3, row.size())
.forEach(i -> row.set(i, String.format("%.2f", (Double) row.get(i))));
}
}
return tables;
}
public static List<List<Object>> getTestData() {
String dumpData =
"""
"63","2024-10-15 01:34:04","FDUSD","base","88.67368551","0.00000000","88.67368551","88.67368551","0.00000000","0.00000000","88.67368551",
"64","2024-10-15 01:34:04","BTC","normal","0.00000000","0.00003000","0.00003000","0.00000000","1.97939640","1.97939640","1.97939640",
"65","2024-10-15 01:34:04","PEPE","hide","0.03500000","0.00000000","0.03500000","0.00000038","0.00000000","0.00000000","0.00000038",
"9993",
"66","2024-10-15 01:34:04","BNB","hide","0.00964743","0.00000000","0.00964743","5.69970342","0.00000000","0.00000000","5.69970342",
"9",
"67","2024-10-15 01:34:04","EUR","ignore","0.10000000","0.00000000","0.10000000","0.00000000","0.00000000","0.00000000","0.00000000",
"68","2024-10-15 01:34:04","NFT","ignore","836.07496490","0.00000000","836.07496490","0.00000000","0.00000000","0.00000000","0.00000000",
"69","2024-10-15 01:34:04","ETHW","ignore","0.00524000","0.00000000","0.00524000","0.00000000","0.00000000","0.00000000","0.00000000",
"70","2024-10-15 02:34:04","FDUSD","base","88.67368551","0.00000000","88.67368551","88.67368551","0.00000000","0.00000000","88.67368551",
"71","2024-10-15 02:34:04","BTC","normal","0.00000000","0.00003000","0.00003000","0.00000000","1.97733750","1.97733750","1.97000000",
"73374999999998",
"72","2024-10-15 02:34:04","PEPE","hide","0.03500000","0.00000000","0.03500000","0.00000038","0.00000000","0.00000000","0.00000038",
"73","2024-10-15 02:34:04","BNB","hide","0.00964743","0.00000000","0.00964743","5.70259765","0.00000000","0.00000000","5.70259765",
"74","2024-10-15 02:34:04","EUR","ignore","0.10000000","0.00000000","0.10000000","0.00000000","0.00000000","0.00000000","0.00000000",
"75","2024-10-15 02:34:04","NFT","ignore","836.07496490","0.00000000","836.07496490","0.00000000","0.00000000","0.00000000","0.00000000",
"76","2024-10-15 02:34:04","ETHW","ignore","0.00524000","0.00000000","0.00524000","0.00000000","0.00000000","0.00000000","0.00000000",
"77","2024-10-15 03:34:04","FDUSD","base","84.68387551","0.00000000","84.68387551","84.68387551","0.00000000","0.00000000","84.68387551",
"78","2024-10-15 03:34:04","BTC","normal","0.00000000","0.00003000","0.00003000","0.00000000","1.96849530","1.96849530","1.96000000",
"84952999999997",
"79","2024-10-15 03:34:04","DOGE","normal","0.00000000","17.00000000","17.00000000","0.00000000","1.98849000","1.98849000","1.98849000",
"000000002",
"80","2024-10-15 03:34:04","LTC","normal","0.00000000","0.02980000","0.02980000","0.00000000","1.99809000","1.99809000","1.99809000",
"81","2024-10-15 03:34:04","PEPE","hide","0.03500000","0.00000000","0.03500000","0.00000038","0.00000000","0.00000000","0.00000038",
"82","2024-10-15 03:34:04","BNB","hide","0.00964234","0.00000000","0.00964234","5.66391228","0.00000000","0.00000000","5.66391228",
"83","2024-10-15 03:34:04","EUR","ignore","0.10000000","0.00000000","0.10000000","0.00000000","0.00000000","0.00000000","0.00000000",
"84","2024-10-15 03:34:04","NFT","ignore","836.07496490","0.00000000","836.07496490","0.00000000","0.00000000","0.00000000","0.00000000",
"85","2024-10-15 03:34:04","ETHW","ignore","0.00524000","0.00000000","0.00524000","0.00000000","0.00000000","0.00000000","0.00000000",
"86","2024-10-15 04:34:04","FDUSD","base","82.71880135","0.00000000","82.71880135","82.71880135","0.00000000","0.00000000","82.71880135",
"87","2024-10-15 04:34:04","DOGE","normal","0.00000000","17.00000000","17.00000000","0.00000000","1.99002000","1.99002000","1.99002000",
"88","2024-10-15 04:34:04","LTC","normal","0.00000000","0.02980000","0.02980000","0.00000000","2.00345400","2.00345400","2.00345400",
"89","2024-10-15 04:34:04","BTC","normal","0.00003000","0.00003000","0.00006000","1.97082030","1.97082030","3.94164060","3.94164060",
"90","2024-10-15 04:34:04","PEPE","hide","0.03500000","0.00000000","0.03500000","0.00000038","0.00000000","0.00000000","0.00000038",
"91","2024-10-15 04:34:04","BNB","hide","0.00963983","0.00000000","0.00963983","5.66050935","0.00000000","0.00000000","5.66050935",
"92","2024-10-15 04:34:04","EUR","ignore","0.10000000","0.00000000","0.10000000","0.00000000","0.00000000","0.00000000","0.00000000",
"93","2024-10-15 04:34:04","NFT","ignore","836.07496490","0.00000000","836.07496490","0.00000000","0.00000000","0.00000000","0.00000000",
"94","2024-10-15 04:34:04","ETHW","ignore","0.00524000","0.00000000","0.00524000","0.00000000","0.00000000","0.00000000","0.00000000",
""";
List<List<Object>> list = new ArrayList<>();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dumpData
.lines()
.forEach(
l -> {
String[] split = l.split(",");
if (split.length == 11) {
List<Object> list2 = new ArrayList<>();
try {
String s = split[1];
String v = s.startsWith("\"") ? s.substring(1, s.length() - 1) : s;
list2.add(new java.sql.Timestamp(df.parse(v).getTime()));
} catch (ParseException e) {
throw new RuntimeException(e);
}
for (int i = 2; i < split.length; i++) {
String s = split[i];
String v = s.startsWith("\"") ? s.substring(1, s.length() - 1) : s;
try {
double d = Double.parseDouble(v);
list2.add(d);
} catch (NumberFormatException ignore) {
list2.add(v);
}
}
list.add(list2);
}
});
return list;
}
public static void main(String[] args) throws Exception {
List<List<List<Object>>> data = getTodayData();
for (List<List<Object>> table : data) {
for (List<Object> row : table) {
System.out.println(row);
}
System.out.println();
}
}