+ Reply to Thread
Results 1 to 12 of 12

Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

  1. #1
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    I am stuck trying to join 2 csv files that are located in 2 different locations using ACE.OLEDB.12. I am using Windows 10 Enterprise, 64-bit with Excel 2016 Pro 64-bit.

    test1.csv
    ------------
    Name Address
    Bruce Dayton
    Tony 10880 Malibu Point
    Peter 20 Ingram Street


    test2.csv
    -------------
    Name Age
    Bruce 49
    Tony 48
    Peter 28


    The code is as follows:

    Please Login or Register  to view this content.
    Right now i am getting a `Syntax error in FROM Clause`. I tried removing the Space from the TEST FOLDER, but same error. I am not sure about the syntax of the SQL query or whether ACE.OLEDB.12 is able to join CSV files from different paths, just like it is able to join Excel files from different paths.

    Please note, i am not using `MICROSOFT ACCESS TEXT DRIVER` for the csv files as it i see it is unable to handle spaces in the csv filepaths.

    Appreciate your help here.
    Attached Files Attached Files
    Last edited by junoon; 10-06-2019 at 05:11 AM. Reason: for @Jindon s perspective

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    Didn't read it all but when text(csv) file, from close should look like
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    Hi @Jindon, sorry i am confused. Can you elaborate a working example with the above code example? i have edited the post to show you the simple csv's. I have tried various combinations, but i think i am missing the correct syntax. Secondly, there are spaces in the csv filepaths as shown in the above example e.g. 'TEST FOLDER'. These paths are originally network paths, where the 2 files lie on the same network drive, but in different folders (paths may contain spaces). How do i escape these properly?

    I have also posted the same issue faced with `MICROSOFT ACCESS TEXT DRIVER` here.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    I don't know if it is possible, but what is the column separator for the file?
    csv usually have comma, but obviously it is not, so better upload a csv files.

  5. #5
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    They are comma delimited files. I have tried this code with other csv files also. But i have uploaded the 2 sample files for your perusal. I have only added double-quotes as text qualifiers to the sample files, as the original files have them as text-qualifiers.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    I have done with multiple Excel under multiple folders, but no csv files.

    This is to make it easy.
    Copy the second selected file to the same folder of the first csv file, if folders are different...
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    Actually @Jindon, i cannot copy the files into same folders as these are located on our company network drive and created/updated by other teams. It would lead to confusion.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    Then alternative would be copy both files to a temp folder in local then process.

    Otherwise I can not help, so wait for some one to comes in.

  9. #9
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    @Jindon, I actually got it to work though getting a power query like error (listing below). See the syntax of enclosing the filepath using `back-ticks`. Also the INNER JOIN gets replaced with a "," and the ON gets replaced with a WHERE Clause.

    Please Login or Register  to view this content.

    While the code runs now, it generates a Power Query like Frown Error:

    Please Login or Register  to view this content.
    I do have some power queries defined in the workbook which reference the files. Could it be because of them? Or are you aware of such an error and its solution? I will remove the queries and their connections and try again.

  10. #10
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    Removed all power queries and connections. Still the frown error! But table gets generated. Any ideas?

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    I can not help you about PQ.

    Some one else will give you a hand.

  12. #12
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Join 2 csv files from different paths having spaces, using ACE.OLEDB.12 in Excel VBA

    Thank you @Jindon for all your help. :-)

    I finally got it working without the Power Query FROWN error. Listing the steps i took:
    1. Removed all power queries in Excel workbook.
    2. Installed latest Office 2016 Sept 3 updates from the following MS site.
    3. Rebooted my System.

    The 2nd AND / OR the 3rd point may have resolved the issue, as i cannot see it is documented on MS site (my trial & error).

    For those who may face the same issue, the SQL QUERY SYNTAX is as shown in the above code. I was also able to use this same SYNTAX with ACE.OLEDB.12 Driver and it works fast and fine in both cases.

    Hope this helps!
    Last edited by junoon; 10-06-2019 at 08:39 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. how do I join multiple excel files into 1 file?
    By John in forum Excel General
    Replies: 7
    Last Post: 08-05-2015, 10:56 AM
  2. How to Join Two Excel Files Consolidate Files
    By danitydazzle in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 03-07-2014, 06:42 PM
  3. Name definitions as files or paths
    By fitzt70 in forum Excel General
    Replies: 1
    Last Post: 11-28-2013, 07:17 PM
  4. Rename files and store them at different paths.
    By Hjahren in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-19-2010, 09:31 AM
  5. Identify identical files names w/ different url paths
    By sc0tt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-25-2008, 10:18 AM
  6. [SOLVED] Delete Spaces and Join Text in Cell
    By Diggsy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-04-2005, 11:05 PM
  7. Excel files via FTP are read-only if spaces in the name
    By Dave Hall in forum Excel General
    Replies: 0
    Last Post: 02-10-2005, 11:06 PM
  8. [SOLVED] Looking for files with UNC paths
    By CQMMAN in forum Excel General
    Replies: 1
    Last Post: 01-13-2005, 08:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1