Solved

I need help importing a CSV file in MS Access 2000 that has commas embedded.

Posted on 2014-10-21
7
313 Views
Last Modified: 2014-11-13
Hello Experts,

I am using Access 2K on Windows XP Pro.

I am trying to import a text file that includes commas.
I know that the data should be enclosed in double quotes but this is not working for me.

Here is the text:
Line Number,Action,Status,ErrorCode,ErrorMessage,Code,Message,ItemID,ReferenceID,ApplicationData,StartTime,EndTime,AuctionLengthFee,BoldFee,BorderFee,BuyItNowFee,CategoryFeaturedFee,CurrencyID,FeaturedFee,FeaturedGalleryFee,FixedPriceDurationFee,GalleryFee,GiftIconFee,HighlightFee,InsertionFee,InternationalInsertionFee,ListingDesignerFee,ListingFee,PhotoDisplayFee,PhotoFee,ProPackBundleFee,ReserveFee,SchedulingFee,SubtitleFee,CustomLabel,PrivateNotes,BasicUpgradePackBundleFee,ValuePackBundleFee,ProPackPlusBundleFee,SellerInventoryID,CrossBorderTradeNorthAmericaFee,CrossBorderTradeGBFee,RefundFromSeller,TotalRefundToBuyer,CorrelationID
2,Add,Warning,"21916981-20169","Warning - Ignore Shipping Cost when free shipping is enabled.--Warning - Invalid store category ID, 0, since it is non-leaf.  So item has been listed to the Other store category-0, since it is non-leaf.  So item has been listed to the Other store category-",,,281474543711,,,2014-10-21T20:41:22.526Z,2014-11-20T20:41:22.526Z,0.0,0.0,0.0,0.0,0.0,USD,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0000-000784,,0.0,0.0,0.0,,,,,,,

The problem begins when it reads this field:

,"Warning - Ignore Shipping Cost when free shipping is enabled.--Warning - Invalid store category ID, 0, since it is non-leaf.  So item has been listed to the Other store category-0, since it is non-leaf.  So item has been listed to the Other store category-",

As soon as it hits the comma after ID, the import gets messed up.

Here is my code to do the import:

'Import the first file in the Import Directory into the TEMP file
    DoCmd.TransferText acImportDelim, "File Exchange Response Import Specification", "FileExchangeResponseTEMP", strFilePath, True

MS Excel 2000 successfully imports the file.
0
Comment
Question by:pcalabria
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 35

Accepted Solution

by:
PatHartman earned 167 total points
ID: 40395813
Do you also have double quotes selected as the text delimiter in your import spec?  Technically the .csv format is very flexible and only the actual fields that need the extra text delimiting because they contain the field delimiter need to be enclosed in quotes.
0
 
LVL 24

Expert Comment

by:NVIT
ID: 40395825
Have you tried other Import specs? e.g. Try changing the Import specification manually via File, Get External Data, Import, Files of type (try Text Files)
0
 

Author Comment

by:pcalabria
ID: 40396065
Pat.. Yes. double quotes used as delimiter.

NewVillage..sorry I didn't understand can you explain?
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 24

Assisted Solution

by:NVIT
NVIT earned 167 total points
ID: 40396072
If you have Access 2000 program available, you can see if it works with a manual import. Be sure to do it using a test table file, not your production table.

From the menu: File, Get External Data, Import, Files of type (Text Files)
Select your csv file.
Pick Import.
In the Wizard, pick Advanced.
Delimited
Field delimiter: ,
Text qualifier: "
Set other options as desired.
Save as: PertinentFilename
OK.
Follow through the wizard to see if it works.

If it works, try your code with the new spec:
DoCmd.TransferText acImportDelim, "PertinentFilename", "FileExchangeResponseTEMP", strFilePath, True
0
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 166 total points
ID: 40396284
All you need is to carefully adjust an import specification - click Advanced and proceed.

It is saved in the attached database as CustomImportSpecification.
Right-click the file, Save As .., change the file name to imp.mdb.

/gustav
imp.mdb
imp.txt
0
 

Author Closing Comment

by:pcalabria
ID: 40438796
Thank you all!

My problem is solved, and all of your made suggestions that helped me find the solution.  The first problem was that I did not have the text qualifier set to ".  I believe this is what Pat was saying, but the term delimiter through me off track as I thought she was referring to a text delimited file.  My oversight.

Second, I was not able to change the import specification because of a problem with Access, and did not have the original disc available to run the repair option.

All is importing properly now, with the text qualifier properly set, and I've been able to repair my installation so I can even create new export specifications.  

Thanks again!
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40439411
You are welcome!

/gustav
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now