CSV file with a comma in some text fields how to import

etaf

Well-known Member
Joined
Oct 24, 2012
Messages
8,358
Office Version
  1. 365
Platform
  1. MacOS
Access version 2010 and excel version 2010

Hi

I have a CSV file with all full post codes in UK and some other demographic info

the 3rd field is a tet field with a city name - unfortunately on some of the records they have included a comma
so

Bristol, city of
instead of
Bristol city of

for example

and so my data splits on this comma and then all the other fields do not match up

because the import wizard is splitting the data on the comma at the first screen, I cant skip that field only just import the data fields I need

any suggestions on how to fix

the file is too large for excel

and i thought of using note pad and just selecting the first half of the data file - pasting into excel and then sorting on one of the columns at i can then group the incorrect fields and then
delete shift left on those entries = laborious, and also its taking hours to scroll down the text file

I hoped to be able to select - find say post code ME and then that would highlight the select = but that does not work

any suggestions to save me a few hours tomorrow welcome

thanks
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Where/how is this CSV being created initially?
The standard protocol of a CSV file is that any entry that has commas in it (that are not delimiters but actual data) should be enclosed with Text Qualifiers, usually double-quotes.
Then when importing into most programs, there is the option of telling it what to use as Text Qualiifers (Access has this option).
This is how Access (or any other program) can differentiate commas that are part of the data from commas that are delimiters. Otherwise, there is no way for the program to know what the difference is.

So for example, let's say you have a simple file of full names and ages, but some of the full names had commas in it, here is how it might look with the Text Qualifiers.

Code:
Name,Age
John Doe,17
"Bill Smith, Jr",25
Dana Jones,34
"Tom Davis, III",9

If your data does not already have these Text Qualifiers in it, I would recommend going back to the source where the files are being created and request that they do this. If you are not sure whether or not they are already included, open the CSV in NotePad or WordPad (NOT in Excel), and see if you can find any Text Qualifiers.
 
Upvote 0
thanks

yes, it does have the "" around the field - so I must be importing incorrectly some how


I saw the


"bristol,
City of"
in to cells - when I copied a sample into excel and then also say it imported into one cell


so its years since I have used access


I just used the external > text> told it was delimited > do i need to tell it about the "," fields ?
where do I tell it to use the text qualifiers ?


the csv has been supplied from an external source
 
Upvote 0
just tested on a small dummy file - I see the option now dah!! thanks - saved me a few hours tomorrow :) :)
 
Upvote 0
Cool! Glad you got it all worked out now!
 
Upvote 0

Forum statistics

Threads
1,215,990
Messages
6,128,155
Members
449,427
Latest member
jahaynes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top