Results 1 to 5 of 5
  1. #1
    JeffGrant is offline Novice
    Windows 7 64bit Office 365
    Join Date
    Oct 2021
    Posts
    9

    How do I import a csv file with spaces in Line 1, the field names

    Hi All,



    I have been trying unsuccessfully to import csv files where Line 1 are the field names, but there are spaces in the names.

    If I wrap the field names in quotes, no problem, but the issue is that the csv files are delivered to me everyday and changing the structure from the supplier is not really a possibility.

    Currently I use PQ in Excel to massage the data, but the data is now getting to big and so PQ isn't going to cope for much longer.

    I don't really want to change the csv data structure anyway because there are several data types in the file and and I dont want them to all be set as being short text.

    All suggestions are graciously received.

    Thanks in advance

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    how are you trying to import? copy/paste? import function on ribbon? transfertext in vba?

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Hi Jeff

    I would create a Macro in Excel which removes any spaces in Field names prior to carrying out the Import
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  4. #4
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I use code to process my test files. I used code examples site create my import routine. The csv files I imported (once a month) sometimes had over 3,000 lines in them.

    I wrote code to select the text file to be imported (using the File System Object), then read each line from the text file and processed it - removes spaces, did calculations, wrote it to the new record.
    Or you can pick the file, use "DoCmd.TransferText" (with an Import Specification) to copy the data to a temp table (the data is temporary, not the table), then copy the data the the final table(s) using queries or code.


    Does the csv file name change every day??

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    OP has started a new thread on the same subject here https://www.accessforums.net/showthr...584#post485584

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Import .csv file line item by line with modifications
    By jmichaels in forum Import/Export Data
    Replies: 22
    Last Post: 04-05-2020, 01:44 PM
  2. Replies: 2
    Last Post: 11-21-2018, 05:53 AM
  3. Replies: 6
    Last Post: 09-29-2017, 04:58 PM
  4. Excel Import - File with row spaces
    By Jackfam58 in forum Import/Export Data
    Replies: 1
    Last Post: 04-13-2011, 07:35 PM
  5. Import File Names
    By cassidym in forum Import/Export Data
    Replies: 3
    Last Post: 01-11-2011, 03:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums