Importing From CSV File Truncation problem

jpskiller

New member
Local time
Today, 21:49
Joined
Nov 29, 2016
Messages
8
Hi,

I have been given a large CSV file extract where the column headers go upto Range DX.


I have tried the following but it seems to truncate the headers which is causing it to think there is a duplication due to some headers being very similar.

These are example headers
Exit Survey - Survey 2 - Based on your experience today, how likely are you to [shop/bank/xxx] with us again?

Exit Survey - Survey 2 - Based on your experience today, how likely are you to refer us to friends or family?

It truncates it down to
Exit Survey - Survey 2 - Based on your experience today, how lik

It truncates them to 64 chars long.


Code:
Dim db As DAO.Database
     ' Re-link the CSV Table
     Set db = CurrentDb
     On Error Resume Next:   db.TableDefs.Delete "tbl_WebHistory_Raw_1":   On Error GoTo 0
     db.TableDefs.Refresh
     
  
     DoCmd.TransferText TransferType:=acLinkDelim, TableName:="tbl_WebHistory_Raw_1", FileName:=mypath & "test.csv", HasFieldNames:=True
    db.TableDefs.Refresh

   
   db.Execute "INSERT INTO tbl_WebHistory_Raw SELECT * FROM tbl_WebHistory_Raw_1"
     db.Close
     Set db = Nothing


using access 2010

Any ideas how I get round this

NOTE : Found out I can get the file in JSON format, not worked with that before
 
Last edited:
I don't understand the truncation.
Can you show us some sample records in the csv?
 
Tried it with both CSV and xlsx and it seems right what you write.
But on the other hand, a column name with more than 60 characters, how can you handle this?
It seems that your headername is a question. I am not aware of the rest of your table, I guess it contains all the answers yes / no from all customers.
Can't you rename your columns to Q1, Q2 etc and store the real questions as string in TableQuestions and the answers in TableAnswers
 
Last edited:
Field names are limited to 64 character according to the Access 2016 Specification so if you are going to use Access you'll need a different approach. I believe if you change HasFieldNames:=True to False you will at least be able to get the data into Access with the fields being F1, F2, etc
 
Thanks guys,

Yes the column names are question based.

I have found only 4 columns with names that are too long and the 64 character limit is causing duplicates, so as suggested I have renamed those columns before doing the import and now works fine.
 

Users who are viewing this thread

Back
Top Bottom