Skip to content

Commit 516a2e1

Browse files
committed
Merge pull request #9 from louisjimenez/carriage-return-fix
Replace carriage returns with new lines when parsing csvs
2 parents b2ecf4c + f8d8c08 commit 516a2e1

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

dist/angular-csv-import.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/*! angular-csv-import - v0.0.14 - 2014-11-25
2-
* Copyright (c) 2014 ; Licensed */
1+
/*! angular-csv-import - v0.0.14 - 2015-02-10
2+
* Copyright (c) 2015 ; Licensed */
33
'use strict';
44

55
var csvImport = angular.module('ngCsvImport', []);
@@ -19,7 +19,7 @@ csvImport.directive('ngCsvImport', function() {
1919
template: '<div><div ng-show="header && headerVisible"><div class="label">Header</div><input type="checkbox" ng-model="header"></div>'+
2020
'<div ng-show="separator" ><div class="label">Seperator</div><input type="text" ng-change="changeSeparator" ng-model="separator"></div>'+
2121
'<div><input class="btn cta gray" type="file"/></div></div>',
22-
link: function(scope, element) {
22+
link: function(scope, element) {
2323
element.on('keyup', function(e){
2424
if ( scope.content != null ) {
2525
var content = {
@@ -37,7 +37,7 @@ csvImport.directive('ngCsvImport', function() {
3737
reader.onload = function(onLoadEvent) {
3838
scope.$apply(function() {
3939
var content = {
40-
csv: onLoadEvent.target.result,
40+
csv: onLoadEvent.target.result.replace(/\r\n|\r/g,'\n'),
4141
header: scope.header,
4242
separator: scope.separator
4343
};
@@ -92,4 +92,4 @@ csvImport.directive('ngCsvImport', function() {
9292
};
9393
}
9494
};
95-
});
95+
});

dist/angular-csv-import.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/angular-csv-import.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ csvImport.directive('ngCsvImport', function() {
1717
template: '<div><div ng-show="header && headerVisible"><div class="label">Header</div><input type="checkbox" ng-model="header"></div>'+
1818
'<div ng-show="separator" ><div class="label">Seperator</div><input type="text" ng-change="changeSeparator" ng-model="separator"></div>'+
1919
'<div><input class="btn cta gray" type="file"/></div></div>',
20-
link: function(scope, element) {
20+
link: function(scope, element) {
2121
element.on('keyup', function(e){
2222
if ( scope.content != null ) {
2323
var content = {
@@ -35,7 +35,7 @@ csvImport.directive('ngCsvImport', function() {
3535
reader.onload = function(onLoadEvent) {
3636
scope.$apply(function() {
3737
var content = {
38-
csv: onLoadEvent.target.result,
38+
csv: onLoadEvent.target.result.replace(/\r\n|\r/g,'\n'),
3939
header: scope.header,
4040
separator: scope.separator
4141
};
@@ -90,4 +90,4 @@ csvImport.directive('ngCsvImport', function() {
9090
};
9191
}
9292
};
93-
});
93+
});

0 commit comments

Comments
 (0)