0

I'm trying to extract some value from *.csv .The file looks like this:

enter image description here

with a following code I get a recordset

Function getCN_Ace16_csv(ByVal dbPath As String) As Object
    Set getCN_Ace16_csv = CreateObject("ADODB.Connection")
    getCN_Ace16_csv.connectionString = "Provider=Microsoft.ACE.OLEDB.16.0;Data Source=" & dbPath _
                                    & "; Extended Properties=""text;HDR=Yes;FMT=Delimited"""
End Function

Function foo (ByRef report as Object) as Boolean
    Set myConn = CN.getCN_Ace16_csv(report.ParentFolder.path)
    myConn.Open
    Set RS = myConn.Execute("SELECT * FROM [" & report.Name & "]")
End Function

When I get the recordset I don't see header names

For the first field a name is "п»ï" instead of "Product Details"

enter image description here

For all other "F2","F3" etc.

enter image description here

Have no idea how to extract info with a correct fields.Name Thank you for any help.

I don't want to use textstream - file is not big 10 - 20 rows, but it's a lot of code for a correct parsing.

7
  • Could be something about encoding, maybe here there is something that may help. Commented Aug 14, 2023 at 19:46
  • If it's not a large file it would be fast to open the file in excel (if that's where you're wrking) Commented Aug 14, 2023 at 20:11
  • @OranG.Utan thank you for the link. Seems very close to my issue, but the problem is that query doesn't see fields name there no abracadabra it's shown simply like F2,F3,F4 lke there no any header in the file. CSV also is a UTF-8 with BOM Commented Aug 15, 2023 at 13:27
  • @TimWilliams, thank you for your reply. There are 2 problems Frist - there are too many files like that and I want to automate the process. Second - its UTF-8 with BOM and while opening it's puts 1 line - one cell. Spliting also a problem - there are commas in values. Commented Aug 15, 2023 at 13:33
  • Your values with commas are quoted though, so that shouldn't be a problem for Excel to handle. Commented Aug 15, 2023 at 15:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.