Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in parsing csv #120

Closed
konstantinzolotarev opened this issue Jul 16, 2013 · 1 comment
Closed

Error in parsing csv #120

konstantinzolotarev opened this issue Jul 16, 2013 · 1 comment

Comments

@konstantinzolotarev
Copy link

I'm using this script

var csv = require('csv');

// node samples/string.js
csv()
.from.string(
  '55.90540000776531, 12.159800000637293, "C", 400, "something", "OK", "Test, text", "test@ttt.com"',
  {comment: '#'} )
.to.array( function(data){
  console.log(data)
} );

And have an output:

    [ [ '55.90540000776531',
' 12.159800000637293',
' "C"',
' 400',
' "something"',
' "OK"',
' "Test',
' text"',
' "test@ttt.com"' ] ]

' "Test', ' text"', is one value and souldn't be spitted.

@wdavidw
Copy link
Member

wdavidw commented Jul 17, 2013

Quotes dont follow coma (the field separator). You should remove the spaces or use the "trim" option. The following work:

csv()
.from.string(
  '55.90540000776531, 12.159800000637293, "C", 400, "something", "OK", "Test, text", "test@ttt.com"',
  trim: true)
.to.array (data) ->
  console.log data[0]
  next()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants