fixed bug where quote existed in non-quoted field

This commit is contained in:
FourierTransformer 2016-11-12 17:44:41 -06:00
parent 49baa6df90
commit a94461c347
5 changed files with 20 additions and 7 deletions

View File

@ -1,9 +1,9 @@
package = "ftcsv"
version = "1.1.2-1"
version = "1.1.3-1"
source = {
url = "git://github.com/FourierTransformer/ftcsv.git",
tag = "1.1.2"
tag = "1.1.3"
}
description = {

View File

@ -1,5 +1,5 @@
local ftcsv = {
_VERSION = 'ftcsv 1.1.2',
_VERSION = 'ftcsv 1.1.3',
_DESCRIPTION = 'CSV library for Lua',
_URL = 'https://github.com/FourierTransformer/ftcsv',
_LICENSE = [[
@ -187,9 +187,11 @@ local function parseString(inputString, inputLength, delimiter, i, headerField,
fieldStart = i + 2
-- print("fs+2:", fieldStart)
-- identifies the escape toggle
elseif currentChar == quote and nextChar ~= quote then
-- print("ESCAPE TOGGLE")
-- identifies the escape toggle.
-- This can only happen if fields have quotes around them
-- so the current "start" has to be where a quote character is.
elseif currentChar == quote and nextChar ~= quote and fieldStart == i then
-- print("New Quoted Field", i)
fieldStart = i + 1
i, doubleQuoteEscape = M.findClosingQuote(i+1, inputLength, inputString, quote, doubleQuoteEscape)
-- print("I VALUE", i, doubleQuoteEscape)
@ -345,7 +347,7 @@ function ftcsv.parse(inputFile, delimiter, options)
end
-- parse through the headers!
local headerField, i = parseString(inputString, inputLength, delimiter, 0)
local headerField, i = parseString(inputString, inputLength, delimiter, 1)
i = i + 1 -- start at the next char
-- make sure a header isn't empty

View File

@ -0,0 +1,2 @@
"Country","City","AccentCity","Region"
af,dekh"iykh'ya,Dekh"iykh'ya,13
Can't render this file because it contains an unexpected character in line 2 and column 8.

View File

@ -0,0 +1,8 @@
[
{
"Country": "af",
"City": "dekh\"iykh'ya",
"AccentCity": "Dekh\"iykh'ya",
"Region": "13"
}
]

View File

@ -23,6 +23,7 @@ local files = {
"newlines",
"newlines_crlf",
"quotes_and_newlines",
"quotes_non_escaped",
"simple",
"simple_crlf",
"utf8"