Code Monkey home page Code Monkey logo

Comments (7)

Senipah avatar Senipah commented on June 6, 2024 1

Should do. That's actually part of the reason this bug occurred. These headers sometimes have varying numbers of spaces:

"Field with 
multiple lines" ,"Another field 
with some 
line breaks inside" , "Include some  comma, for test, and some [""] Quotes" , "Normal field here" 

That whole sample file parses without issue now.


Also worth noting that all strings parsed from the CSV are trimmed in this function, so that " some field here " is stored as some field here:

Private Function UnquoteString(ByRef element As String) As String
    Dim localElement As String
    localElement = Trim$(element)
    If Asc(Left$(localElement, 1)) = 34 And Asc(Right$(localElement, 1)) = 34 Then
        'trim string delimiters
        localElement = Mid$(localElement, 2, Len(localElement) - 2)
    End If
    UnquoteString = Trim$(localElement)
End Function

from vba-better-array.

Senipah avatar Senipah commented on June 6, 2024 1

Just tested this as a CSV:

"Field with 
multiple lines" ,"Another field 
with some 
line breaks inside   "    , "Include some  comma, for test, and some [""] Quotes" , "Normal field here" 
1, 2,    3    ,4 
            Field 1,            Field 2                ,               Field 3 , Field 4

and I get this as the output:

Field with multiple lines Another field with some line breaks inside Include some comma, for test, and some [""] Quotes Normal field here
1 2 3 4
Field 1 Field 2 Field 3 Field 4

So yes is the answer

from vba-better-array.

ws-garcia avatar ws-garcia commented on June 6, 2024 1

Thanks for your answer! I have successfully updated benchmark on a local branch. In the next few days I'll put in online and alert to you. So, delayed by an unexpected errors fixes, I hope the code be available to the community very soon. 😎

from vba-better-array.

Senipah avatar Senipah commented on June 6, 2024

Hey! Thank you so much for letting me know about this!

It was a simple off-by-one error as far as I can tell - the above commit solves the issue by changing:

                    j = j + 1
                    cursor = j + 1

To:
cursor = j + 2

from vba-better-array.

Senipah avatar Senipah commented on June 6, 2024

I'd be very grateful if you could retest on your end if you find the time (release 1.6.1). Of course, if there are still problems I will happily reopen this issue.

from vba-better-array.

Senipah avatar Senipah commented on June 6, 2024

I also just fixed an issue where string in CSV weren't getting unquoted correctly in v1.6.2 just now, so that's the latest release

from vba-better-array.

ws-garcia avatar ws-garcia commented on June 6, 2024

Only a question, before do anything, can your parser handle an variable number of trailing spaces? i.e. A secuence like Space(2) & "," & Space(1) or Space(4) & "," and en of a record.

from vba-better-array.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.