File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -33,17 +33,16 @@ const gtfsplus = (state = {
3333 case 'RECEIVE_GTFSPLUS_CONTENT' :
3434 const newTableData = { }
3535 for ( let i = 0 ; i < action . filenames . length ; i ++ ) {
36+ // split file into lines
3637 const lines = action . fileContent [ i ] . split ( / \r \n | \r | \n / g)
3738 if ( lines . length < 2 ) continue
38- // console.log(lines[0])
3939 const fields = lines [ 0 ] . split ( ',' )
40- // console.log(fields)
41- // console.log(fields[fields.length - 1])
40+ const COLUMN_REGEX = / , (? = (?: (?: [ ^ " ] * " ) { 2 } ) * [ ^ " ] * $ ) /
4241 const tableName = action . filenames [ i ] . split ( '.' ) [ 0 ]
4342 newTableData [ tableName ] = lines . slice ( 1 )
44- . filter ( line => line . split ( ',' ) . length === fields . length )
43+ . filter ( line => line . split ( COLUMN_REGEX ) . length === fields . length )
4544 . map ( ( line , rowIndex ) => {
46- const values = line . split ( ',' )
45+ const values = line . split ( COLUMN_REGEX )
4746 const rowData = { origRowIndex : rowIndex }
4847 for ( let f = 0 ; f < fields . length ; f ++ ) {
4948 rowData [ fields [ f ] ] = values [ f ]
You can’t perform that action at this time.
0 commit comments