diff options
author | S129778 <S129778@S129778.campus.tue.nl> | 2014-05-15 21:14:44 +0200 |
---|---|---|
committer | S129778 <S129778@S129778.campus.tue.nl> | 2014-05-15 21:15:54 +0200 |
commit | 9b7fa7f91a12503e60af654b8fe2f03a17b767fd (patch) | |
tree | 3c471cae71279c12b1226cd003843c0c2e3d9905 /src | |
parent | 0d34f1276215d1c2985fdffddcc9d3ac1bfa9f19 (diff) | |
download | Goldfarmer-9b7fa7f91a12503e60af654b8fe2f03a17b767fd.tar.gz |
added disco output
Diffstat (limited to 'src')
-rw-r--r-- | src/main/Analyzor.java | 26 | ||||
-rw-r--r-- | src/main/FarmShell.java | 4 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/main/Analyzor.java b/src/main/Analyzor.java index 639f385..754e593 100644 --- a/src/main/Analyzor.java +++ b/src/main/Analyzor.java @@ -5,6 +5,8 @@ import database.QueryUtils; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -172,7 +174,29 @@ public class Analyzor { } } } - + + //generate csv for disco from the query + public void disco(String query) throws SQLException, FileNotFoundException, UnsupportedEncodingException{ + query(query); + PrintWriter writer = new PrintWriter("output.csv", "UTF-8"); + while(data.next()){ + for(int i = 1; i<data.getMetaData().getColumnCount();i++){ + if(data.getObject(i)==null){ + writer.print(", "); + } else { + writer.print(data.getObject(i).toString().replaceAll("[,\n]", " ")+", "); + } + } + if(data.getObject(data.getMetaData().getColumnCount())==null){ + writer.println(" "); + } else { + writer.println(data.getObject(data.getMetaData().getColumnCount()).toString().replace(",", " ")); + } + } + writer.close(); + } + + //replaces punctuation so it will be splitted //also removes urls private String splitPunctToWords(String text) { diff --git a/src/main/FarmShell.java b/src/main/FarmShell.java index 7186c2f..044d3d3 100644 --- a/src/main/FarmShell.java +++ b/src/main/FarmShell.java @@ -130,6 +130,9 @@ public class FarmShell { case wordcloud: getAnalyzor().makeWordCloud(params[0]); break; + case disco: + getAnalyzor().disco(params[0]); + break; case help: for (String line : HELP) { System.out.println(line); @@ -159,6 +162,7 @@ public class FarmShell { filterbots("marks all users as bot or not", 1), sentiment("analyzes all tweets on positivity (about a brand)", 1), wordcloud("makes a wordcloud of the text of the tweets", 1), + disco("makes a outputfile for disco",1), exit("Returns to shell"), help("Get help"); |