-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring table; update java dependencies
- Loading branch information
1 parent
800b47e
commit ea5cafc
Showing
11 changed files
with
73 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package tsdb.util; | ||
|
||
import java.io.IOException; | ||
import java.io.Reader; | ||
|
||
import com.opencsv.CSVParser; | ||
import com.opencsv.CSVParserBuilder; | ||
import com.opencsv.CSVReader; | ||
import com.opencsv.CSVReaderBuilder; | ||
|
||
public class TableUtil { | ||
|
||
private static final String UTF8_BOM = "\uFEFF"; | ||
|
||
static CSVReader buildCSVReader(Reader reader, char separator) { | ||
CSVParser csvParser = new CSVParserBuilder().withSeparator(separator).build(); | ||
return new CSVReaderBuilder(reader).withCSVParser(csvParser).build(); | ||
} | ||
|
||
static boolean readHeader(AbstractTable table, CSVReader csvReader) throws IOException { | ||
String[] curRow = csvReader.readNextSilently(); | ||
if(curRow != null) { | ||
String[] columnsNames = curRow; | ||
if(columnsNames.length>0) { // filter UTF8 BOM | ||
if(columnsNames[0].startsWith(UTF8_BOM)) { | ||
columnsNames[0] = columnsNames[0].substring(1, columnsNames[0].length()); | ||
} | ||
} | ||
table.updateNames(columnsNames); | ||
//Logger.info("names: "+Arrays.toString(table.names)+" in "+filename); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters