Results 1 to 12 of 12
  1. #1
    Kurs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    5

    Importing a text file

    I'm trying to import a text file which has 232050 records and 80 fields. I selected the - fixed width option while importing. After the importing was complete, there are only 5 fields populated. I'm not sure where I might be going wrong but I am following all the steps for importing a text file.



    Any help/suggestions would be greatly appreciated.

    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    This is not a comma delimited file? All columns are actually the same width? Want to attach a sample of the text file, maybe a 100 lines?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Kurs View Post
    I'm trying to import a text file which has 232050 records and 80 fields. I selected the - fixed width option while importing. After the importing was complete, there are only 5 fields populated. I'm not sure where I might be going wrong but I am following all the steps for importing a text file.

    Any help/suggestions would be greatly appreciated.

    Thanks!
    Maybe your text file is not a fixed width file. Are the table fields the correct type for the data?
    Is the file extension ".txt" or ".csv"?

    Care to post a line of the text file - without sensitive data?

  4. #4
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by June7 View Post
    This is not a comma delimited file? All columns are actually the same width? Want to provide a sample of the text file, maybe a 100 lines?
    Drat!!!!! You're first AGAIN!!!

  5. #5
    Kurs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    5
    Thank you all for your responses.
    1. It is not a comma delimited file but there are spaces between each field. Also, the columns are not of the same width.
    2. I'm afraid I cannot attach of sample of it since it is a confidential data. (but i wish i could though :P)
    3. The file extension is .txt

    Steve, I didn't get your second question- "Are the table fields the correct type for the data?"

    Thanks again!

  6. #6
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Kurs View Post
    Thank you all for your responses.
    1. It is not a comma delimited file but there are spaces between each field. Also, the columns are not of the same width.
    2. I'm afraid I cannot attach of sample of it since it is a confidential data. (but i wish i could though :P)
    3. The file extension is .txt

    Steve, I didn't get your second question- "Are the table fields the correct type for the data?"

    Thanks again!
    How about changing the data.... ie if it is a SSN, change it to 123-45-6789

    Steve, I didn't get your second question- "Are the table fields the correct type for the data?"
    If a field type is a long, and the import is trying to enter a text string.... or a NULL, the data won't be saved.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Cannot use fixed width parameter. Use space or tab as the delimiter. Are you using the import wizard or VBA code? If VBA, show code. We don't need real data, just structure. Put dummy names and ssn, whatever, into a file. Just a few lines would be enough, enough to adequately represent the dataset.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Kurs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    5
    The data looks similar to the one in census 2000 ftp raw data (modified) which I have attached. I cannot import this as well.

    Thanks again.census2000geo.txt

  9. #9
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    I looked at the text file you posted; you will not be able to use blanks as a delimiter with that, because a) a lot of the fields are blank, and b) at least one of the fields contains blanks (address). From what I can see, the format is fixed width, that is each field is the same width in each record, but it is NOT space delimited. What looks like one string of characters could be many fields adjacent to each other.

    If this is the case, where each field is the same width in each record, but some fields are blank, my suggestion would be to read each entire record as one string, and then use VBA to split out the separate fields.

    When you said "there were only 5 fields populated" - were the fields populated correctly, and were they the first 5?
    When you used the wizard, and specified fixed-width option - did it not ask you where the field breaks were? It should have.

    HTH

    John

  10. #10
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I would use VBA and the Mid() function.
    Read each line, parse it into variables or an array, create the INSERT query, loop until done.
    Can't tell where the columns start and end in some areas of the sample text.

  11. #11
    Kurs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    5
    Thank you for your response, John.
    The 5 fields populated are not the first 5.
    I'm trying to run it using the fixed width option and wizard. It did ask me where the field breaks were. However, I need to analyze the table and decide on the fields.

    This will help me in moving forward.
    Thanks again for your help.

  12. #12
    Kurs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    5
    Yes. Got that. It might take quite some time to do that!

    Thanks for your help.

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

Similar Threads

  1. Error 3027 when importing text file
    By tym in forum Access
    Replies: 4
    Last Post: 12-12-2011, 12:53 PM
  2. Importing a text file to access
    By Navop in forum Access
    Replies: 2
    Last Post: 11-11-2010, 07:15 PM
  3. Replies: 1
    Last Post: 11-05-2010, 04:31 PM
  4. Skipping headers when Importing a text file.
    By bullwinkle55423 in forum Import/Export Data
    Replies: 1
    Last Post: 09-01-2010, 03:25 PM
  5. Importing text file into Access Table
    By Anthony in forum Import/Export Data
    Replies: 13
    Last Post: 09-23-2009, 04:47 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