Guest User

Untitled

a guest
Oct 25th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package com.github.adriens.open.data.fromages;
  7.  
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.ResultSet;
  11. import java.sql.Statement;
  12. import tech.tablesaw.api.Table;
  13. import tech.tablesaw.reducing.CrossTab;
  14.  
  15. /**
  16. *
  17. * @author salad74
  18. */
  19. public class LintsSample {
  20.  
  21. public static void main(String[] args) {
  22. try{
  23. Table table = Table.read().csv("lints.csv");
  24. System.out.println(table.shape());
  25. System.out.println(table.structure());
  26. // drop the "message" column
  27. table.removeColumns("message");
  28. System.out.println(table.first(5));
  29.  
  30. table.removeColumns("objectName");
  31. table.removeColumns("value");
  32. System.out.println(table.first(5));
  33.  
  34. //
  35. Class.forName("org.h2.Driver");
  36. //Connection conn = DriverManager.getConnection("jdbc:h2:mem:lints", "sa", "");
  37. Connection conn = DriverManager.getConnection("jdbc:h2:~/lints", "sa", "");
  38. Statement stmt = conn.createStatement();
  39. stmt.execute("drop table lints if exists");
  40. stmt.execute("CREATE TABLE LINTS AS SELECT * FROM CSVREAD('lints.csv')");
  41.  
  42. ResultSet rs = stmt.executeQuery("select * from lints limit 10");
  43. while (rs.next()) {
  44. System.out.println(rs.getString("linterId"));
  45. }
  46.  
  47.  
  48. stmt.executeQuery("CALL CSVWRITE('~/grouped-lints.csv', 'select severity, count(*) from lints group by severity')");
  49. System.exit(0);
  50. }
  51. catch(Exception ex){
  52. ex.printStackTrace();
  53. }
  54. }
  55. }
Add Comment
Please, Sign In to add comment