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 = {
33
33
case 'RECEIVE_GTFSPLUS_CONTENT' :
34
34
const newTableData = { }
35
35
for ( let i = 0 ; i < action . filenames . length ; i ++ ) {
36
+ // split file into lines
36
37
const lines = action . fileContent [ i ] . split ( / \r \n | \r | \n / g)
37
38
if ( lines . length < 2 ) continue
38
- // console.log(lines[0])
39
39
const fields = lines [ 0 ] . split ( ',' )
40
- // console.log(fields)
41
- // console.log(fields[fields.length - 1])
40
+ const COLUMN_REGEX = / , (? = (?: (?: [ ^ " ] * " ) { 2 } ) * [ ^ " ] * $ ) /
42
41
const tableName = action . filenames [ i ] . split ( '.' ) [ 0 ]
43
42
newTableData [ tableName ] = lines . slice ( 1 )
44
- . filter ( line => line . split ( ',' ) . length === fields . length )
43
+ . filter ( line => line . split ( COLUMN_REGEX ) . length === fields . length )
45
44
. map ( ( line , rowIndex ) => {
46
- const values = line . split ( ',' )
45
+ const values = line . split ( COLUMN_REGEX )
47
46
const rowData = { origRowIndex : rowIndex }
48
47
for ( let f = 0 ; f < fields . length ; f ++ ) {
49
48
rowData [ fields [ f ] ] = values [ f ]
You can’t perform that action at this time.
0 commit comments