Comments (7)
Thank you for reporting.
I tired your CSV text but ParseCSVToArray does not return null.
I have tried both case of return code CR and CRLF.
My test code is:
Dim csv As Variant
Dim csvText As String
csvText = readFile("C:\Users\xxxx\desktop\test.txt") 'readFile is defined in CSVUtils_Example.
csv = ParseCSVToArray(csvText)
If IsNull(csv) Then
Debug.Print Err.Number & " (" & Err.Source & ") " & Err.Description
End If
"test.txt" contains your CSV text.
What is your situation ?
from vba-csv.
The CSV text is on a ANSI codified file, when I tried to parse it, using your well documented code, I got an null
value returned.
from vba-csv.
First, I defined SDKNstrArray As Variant
; and then I make a call SDKNstrArray = ParseCSVToArray(tmpCSV)
, were the argument was defined as tmpCSV As String
. The inspection window show me the null
value returned after call the function.
from vba-csv.
After a look to your response:
SDKNstrArray = ParseCSVToArray(tmpCSV)
If IsNull(SDKNstrArray) Then
Debug.Print Err.Number & " (" & Err.Source & ") " & Err.description
End If
The above prints the text 10001 (ParseCSVToCollection) Syntax Error in CSV: numbers of fields are different among records
in the immediate window.
from vba-csv.
I tried the following code.
Dim csv As Variant
Dim csvText As String
csvText = """Field with" & vbCr & _
"multiple lines"" , ""Another field" & vbCr & _
"With some" & vbCr & _
"line breaks inside"" , ""Include some comma, for test"" , Normal field here" & vbCr & _
"1, 2, 3 ,4" & vbCr & _
"""Field 1"", ""Field 2"" , Field 3 , ""Field 4"""
Debug.Print csvText
csv = ParseCSVToArray(csvText)
If IsNull(csv) Then
Debug.Print Err.Number & " (" & Err.Source & ") " & Err.Description
End If
Debug.Print UBound(csv, 1)
Debug.Print UBound(csv, 2)
The result in immediate window is
"Field with
multiple lines" , "Another field
With some
line breaks inside" , "Include some comma, for test" , Normal field here
1, 2, 3 ,4
"Field 1", "Field 2" , Field 3 , "Field 4"
3
4
Please check it.
from vba-csv.
The file has some space chars not included in your above test:
"Field with
multiple lines" ,"Another field
with some
line breaks inside" , "Include some comma, for test" , Normal field here
1, 2, 3 ,4
"Field 1", "Field 2" , Field 3 , "Field 4"
But, I think the main problem here is that the file actually use vbCrLf
instead vbCr
char
However, I will check if there are additional vbCrLf
chars in the CSV file that potential may cause the cited error in your code.
from vba-csv.
Definitely, the are an extra vbCrLf
char into the CSV file. This file issue break the logic and generate an error. After remove it, your code successful import the data. Thanks for your replies!
from vba-csv.
Related Issues (3)
- ParseCSVToDictionary HOT 2
- Performance issue HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vba-csv.