mirror of
https://github.com/FourierTransformer/ftcsv.git
synced 2024-11-19 19:54:23 +00:00
fixed bug where quote existed in non-quoted field
This commit is contained in:
parent
49baa6df90
commit
a94461c347
@ -1,9 +1,9 @@
|
|||||||
package = "ftcsv"
|
package = "ftcsv"
|
||||||
version = "1.1.2-1"
|
version = "1.1.3-1"
|
||||||
|
|
||||||
source = {
|
source = {
|
||||||
url = "git://github.com/FourierTransformer/ftcsv.git",
|
url = "git://github.com/FourierTransformer/ftcsv.git",
|
||||||
tag = "1.1.2"
|
tag = "1.1.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
description = {
|
description = {
|
12
ftcsv.lua
12
ftcsv.lua
@ -1,5 +1,5 @@
|
|||||||
local ftcsv = {
|
local ftcsv = {
|
||||||
_VERSION = 'ftcsv 1.1.2',
|
_VERSION = 'ftcsv 1.1.3',
|
||||||
_DESCRIPTION = 'CSV library for Lua',
|
_DESCRIPTION = 'CSV library for Lua',
|
||||||
_URL = 'https://github.com/FourierTransformer/ftcsv',
|
_URL = 'https://github.com/FourierTransformer/ftcsv',
|
||||||
_LICENSE = [[
|
_LICENSE = [[
|
||||||
@ -187,9 +187,11 @@ local function parseString(inputString, inputLength, delimiter, i, headerField,
|
|||||||
fieldStart = i + 2
|
fieldStart = i + 2
|
||||||
-- print("fs+2:", fieldStart)
|
-- print("fs+2:", fieldStart)
|
||||||
|
|
||||||
-- identifies the escape toggle
|
-- identifies the escape toggle.
|
||||||
elseif currentChar == quote and nextChar ~= quote then
|
-- This can only happen if fields have quotes around them
|
||||||
-- print("ESCAPE TOGGLE")
|
-- 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
|
fieldStart = i + 1
|
||||||
i, doubleQuoteEscape = M.findClosingQuote(i+1, inputLength, inputString, quote, doubleQuoteEscape)
|
i, doubleQuoteEscape = M.findClosingQuote(i+1, inputLength, inputString, quote, doubleQuoteEscape)
|
||||||
-- print("I VALUE", i, doubleQuoteEscape)
|
-- print("I VALUE", i, doubleQuoteEscape)
|
||||||
@ -345,7 +347,7 @@ function ftcsv.parse(inputFile, delimiter, options)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- parse through the headers!
|
-- 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
|
i = i + 1 -- start at the next char
|
||||||
|
|
||||||
-- make sure a header isn't empty
|
-- make sure a header isn't empty
|
||||||
|
2
spec/csvs/quotes_non_escaped.csv
Normal file
2
spec/csvs/quotes_non_escaped.csv
Normal 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.
|
8
spec/json/quotes_non_escaped.json
Normal file
8
spec/json/quotes_non_escaped.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"Country": "af",
|
||||||
|
"City": "dekh\"iykh'ya",
|
||||||
|
"AccentCity": "Dekh\"iykh'ya",
|
||||||
|
"Region": "13"
|
||||||
|
}
|
||||||
|
]
|
@ -23,6 +23,7 @@ local files = {
|
|||||||
"newlines",
|
"newlines",
|
||||||
"newlines_crlf",
|
"newlines_crlf",
|
||||||
"quotes_and_newlines",
|
"quotes_and_newlines",
|
||||||
|
"quotes_non_escaped",
|
||||||
"simple",
|
"simple",
|
||||||
"simple_crlf",
|
"simple_crlf",
|
||||||
"utf8"
|
"utf8"
|
||||||
|
Loading…
Reference in New Issue
Block a user