1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-16 06:15:02 -05: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", ";" }) {
String[] field = line.split(delim, 2);
if (field.length >= 2) { if (field.length >= 2) {
map.put(field[0], field[1]); map.put(field[0], field[1]);
break;
}
} }
} }
return map; return map;