Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Fix #30 - Strip BOM from first line of input files (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 authored and barbeau committed Jul 23, 2017
1 parent 322f4a1 commit 3bd069a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/GTFSReadIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class GTFSReadIn {
private List<Stop> stops;
private final String ROUTE_KEY = "route_ref";
private final String NTD_ID_KEY = "ntd_id";
private static final String UTF8_BOM = "\uFEFF";
private static Hashtable<String, Route> allRoutes;
//TODO read agency.txt

Expand Down Expand Up @@ -136,6 +137,9 @@ public List<Stop> readBusStop(String fName, String agencyName, String routes_fNa
{
if (isFirstLine) {
isFirstLine = false;
if (thisLine.startsWith(UTF8_BOM)) {
thisLine = thisLine.substring(1);
}
OperatorInfo.setGtfsFields(thisLine);
thisLine = thisLine.replace("\"", "");
String[] keys = thisLine.split(",");
Expand Down Expand Up @@ -250,6 +254,9 @@ public Hashtable<String, Route> readRoutes(String routes_fName){
while ((thisLine = br.readLine()) != null) {
if (isFirstLine) {
isFirstLine = false;
if (thisLine.startsWith(UTF8_BOM)) {
thisLine = thisLine.substring(1);
}
thisLine = thisLine.replace("\"", "");
String[] keys = thisLine.split(",");
for(int i=0; i<keys.length; i++){
Expand Down Expand Up @@ -321,6 +328,9 @@ public Hashtable<String, HashSet<Route>> matchRouteToStop(String routes_fName, S
while ((thisLine = br.readLine()) != null) {
if (isFirstLine) {
isFirstLine = false;
if (thisLine.startsWith(UTF8_BOM)) {
thisLine = thisLine.substring(1);
}
thisLine = thisLine.replace("\"", "");
String[] keys = thisLine.split(",");
for(int i=0; i<keys.length; i++){
Expand Down Expand Up @@ -362,6 +372,9 @@ public Hashtable<String, HashSet<Route>> matchRouteToStop(String routes_fName, S
while ((thisLine = br.readLine()) != null) {
if (isFirstLine) {
isFirstLine = false;
if (thisLine.startsWith(UTF8_BOM)) {
thisLine = thisLine.substring(1);
}
thisLine = thisLine.replace("\"", "");
String[] keys = thisLine.split(",");
for(int i=0; i<keys.length; i++){
Expand Down Expand Up @@ -441,4 +454,4 @@ public GTFSReadIn() {
allRoutes = new Hashtable<String, Route>();
// readBusStop("C:\\Users\\Khoa Tran\\Desktop\\Summer REU\\Khoa_transit\\stops.txt");
}
}
}

0 comments on commit 3bd069a

Please sign in to comment.