1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

* allow TSV and CSV formats

This commit is contained in:
Reinhard Pointner 2014-12-17 02:19:29 +00:00
parent eaff34998a
commit 400e5f5dcb

View File

@ -91,9 +91,12 @@ public class ExpressionFormatFunctions {
public static Map<String, String> csv(String path) throws IOException { public static Map<String, String> csv(String path) throws IOException {
Map<String, String> map = new LinkedHashMap<String, String>(); Map<String, String> map = new LinkedHashMap<String, String>();
for (String line : Files.readAllLines(Paths.get(path), Charset.forName("UTF-8"))) { for (String line : Files.readAllLines(Paths.get(path), Charset.forName("UTF-8"))) {
String[] field = line.split(";", 2); for (String delim : new String[] { "\t", ";" }) {
if (field.length >= 2) { String[] field = line.split(delim, 2);
map.put(field[0], field[1]); if (field.length >= 2) {
map.put(field[0], field[1]);
break;
}
} }
} }
return map; return map;