Skip to content

Unable to import CSV data from file on AppData path #48

@JRyman

Description

@JRyman

Describe the bug
I have data stored in a subdirectory of AppData e.g., C:\Users\user\AppData\Roaming\project\data.csv that I cannot load normally.

This is the snippet that errors,

    Set csv = New CSVinterface
    With csv.parseConfig
        .path = PROJECT_PATH & "data.csv"
        .dialect.fieldsDelimiter = ","
        .dialect.recordsDelimiter = vbCrLf
    End With
    With csv
        .ImportFromCSV .parseConfig
        .DumpToSheet SheetName:=DATA_SHEET
    End With

I've sourced the error to the FolderExists function within CSVTextStream class. It looks like the detection method here does not work for system folders. FolderExists("C:\Users\user\AppData") always returns False.

Private Function FolderExists(ByVal filePath As String) As Boolean
    FolderExists = CBool(LenB(Dir(filePath, vbDirectory)))
End Function

To Reproduce
Steps to reproduce the behavior:

  1. Add csv file to C:\Users\user\AppData\Roaming\project\data.csv
  2. Attempt ImportFromCSV method of CSVinterface
  3. See error

Expected behavior
Data is imported

Desktop (please complete the following information):

  • OS: 11
  • Host Application: Excel
  • Version: Version 2502 (Build 18526.20546 Click-to-Run)

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedThe issue has been corrected

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions