Results 1 to 14 of 14
  1. #1
    SamuelOu is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    16

    Importing txt unsuccessfully

    Hello,

    I have been trying to import a txt file to my database, however, it pops up same error message when I click finish:

    "The field 'Attribute16Name' contains a start position of '33609'. The maximum start position allowed is 32767."

    and

    "An error occurred trying to save import/export specification 'Txt gt Import specification'"

    Column 'Attribute16Name' has constant value "Handling time" for 18888 rows.

    Any help is appreciated! Thank you.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Just how big is this text file?
    Do you really have more than 32767 characters on each line?
    I can't imagine having that many characters on a single line.
    If so, I think that might be problematic.

  3. #3
    SamuelOu is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    16
    The size of the text file is 215mb: 146 columns and 18888 rows.
    I have six similar files to import and this is not the biggest one.
    I don't have there is more than 32767 characters on each line. However, I am not 100% sure about that.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    yeah that seems exceedingly large for a single line, unless the file is not indicating the end of line with a carriage return/line feed pair and is only using a line feed. Access will choke on it if the carriage return is not there and you can't always tell just by opening the file in a text editor.

    if, visually, the lines are shorter than 32000 characters you may have to run it through a process to insert the carriage returns with something like filesystemobject which will acknowledge line feeds as an end of line.

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Try this, write a module and put this code in it:

    Code:
    dim fs
    dim f
    dim sPath as string
    dim sline
    dim iRow as long
    
    spath = "c:\test\testfile.txt"  '<====== PUT YOUR ACTUAL FILE PATH AND NAME HERE
    set fs = createobject("scripting.filesystemobject")
    set f = fs.opentextfile(spath)
    
    do while f.atendofstream <> true
        irow = irow + 1
        sline = f.readline
        if len(sline) > 32000 then
            debug.print "ROW " & irow & " has " & len(sline) & " characters in it
        endif
    loop
    set fs = nothing
    see if you get anything in your immediate window

  6. #6
    SamuelOu is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    16
    I found that there is a column having more than 30000 characters, I decided to delete that column to avoid this problem.

    However, new issue comes up. Now it pops up " The search key was not found in any record".

    I tried to put "No" on all the Index, still doesn't work.

    Is there any clue to find out why is causing that? Any help is appreciated.

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    When are you getting this error? As you try to import the file? Or before it even gets to that step, like when you're setting up your import spec.

  8. #8
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    I would question 146 columns?? This is a rare table design if normalized.
    Need to know more info about the data.

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    any chance you can supply a sample file with garbage data in it. I am not questioning the 146 fields like orange is because I deal with a file with a similar number of fields from an external source I have no control over but it's a good question to ask... do you have control over the original file you are getting.

  10. #10
    SamuelOu is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    16
    I got this error when I click finish, before saving the importing steps.

    I have no control to the data. It's a standardized file downloaded from a 3rd party website. It got so many field because there are more than 60 attributes which generate at least 120 fields (attribute name, attribute value).

  11. #11
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Two possibilities:
    1. You're trying to import more data than your DB can hold, or
    2. There's a space/other character where there shouldn't be

    Try importing the file into an empty database and see if it works, if it does then you might be too close to the 2GB file size limit to import all the data in your main db.

    It looks like you're using the Import Wizard to import the file. Especially for a file of this size and complexity, I'd recommend coming up with VBA import code, that will allow you to see exactly where the import is failing and give you much greater control over error handling. It would also allow you to maintain a normalized database even if the file itself isn't normalized.

  12. #12
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    What about my previous question about getting a sample file, if the file is coming from a website anyone can access you can give the address and we can take a closer look, if it's proprietary, just create a sample text file and cut and paste some of the original file in there, just make sure to fill in any proprietary information with garbage data.

  13. #13
    SamuelOu is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    16
    For the confidential reason, I'm not allowed to upload a sample file.

    I tried many ways and it finally works when I skip importing the fields contains more than 256 characters.

  14. #14
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Your import will work if you change the fields that have more than 255 characters to LONG STRING in your table design, assuming they are also less than 32000 characters long.


    edit:

    err... long text

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

Similar Threads

  1. Importing XML
    By ampd85 in forum Access
    Replies: 4
    Last Post: 04-22-2014, 08:17 AM
  2. Importing CSV
    By mike02 in forum Access
    Replies: 5
    Last Post: 08-01-2012, 05:21 PM
  3. Importing a PDF
    By JHighley in forum Access
    Replies: 6
    Last Post: 07-24-2012, 08:39 AM
  4. Need help importing to SQL
    By winterh in forum SQL Server
    Replies: 14
    Last Post: 03-28-2012, 12:36 PM
  5. Help with Importing
    By Souperbc in forum Programming
    Replies: 2
    Last Post: 04-13-2011, 12:45 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