mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 08:56:07 +00:00
fix operations being ignored as syntax error when multiple minuses
This commit is contained in:
27
argon_modules/csv/init.ar
Normal file
27
argon_modules/csv/init.ar
Normal file
@@ -0,0 +1,27 @@
|
||||
let read(path) = do
|
||||
f = file.read(path)
|
||||
text = f.text()
|
||||
data = []
|
||||
splitlines = text.split("\n")
|
||||
for (i from 0 to splitlines.length) do
|
||||
values = []
|
||||
in_quotes = false
|
||||
start = 0
|
||||
line = splitlines[i]
|
||||
for (j from 0 to line.length) do
|
||||
char = line[j]
|
||||
if (char == "," && not in_quotes) do
|
||||
value = line[start:j].rightstrip("\r").strip()
|
||||
if (value && value[0] == "\"" && value[-1] == "\"") value = value[1:value.length - 1]
|
||||
value = value.replace("\"\"", "\"")
|
||||
values.append(value)
|
||||
start = j + 1
|
||||
else if (char == "\"") in_quotes = not in_quotes
|
||||
if (j == line.length - 1) do
|
||||
value = line[start:j + 1].rightstrip("\r").strip()
|
||||
if (value && value[0] == "\"" && value[-1] == "\"") value = value[1:value.length - 1]
|
||||
value = value.replace("\"\"", "\"")
|
||||
values.append(value)
|
||||
data.append(values)
|
||||
|
||||
return data
|
||||
Reference in New Issue
Block a user