Importing data from CSV - spaces

  • Thread starter Thread starter IgorM
  • Start date Start date
I

IgorM

Hi
I have a CSV that was created in Excel. Example line:
Opis;Wn PLN;Ma PLN;Wal;W walucie obcej;B100;Koszty ogóln.byd³a miêsn.;
401172;Am.¶r.transp.osobowych;1;
As you can see there are spaces before the number 401172. What should I do
to import that line to Access table with the spaces before the number. When
I set the column type to Text Access a text coulmn type but trims the
spaces.

Thanks for any help.

Kind regards
Igor
 
How will you identify which fields or which values in the fields should have
the leading space or spaces and how do you know how many spaces to add?
 
Hi

I think you misunderstood me. The CSV file contains a text field with a
certain number that is preceded by spaces. I want Access to retain those
spaces after the file is imported to the table. Unfortunatelly Access trims
the spaces.

Thanks for any help.
 
I fully undestood the question. But, to give you an answer, I need to know
the rules for the spaces. First, to keep the spaces, the destination field
has to be a text field. If it is a numeric field, you loose any spaces (they
aren't numbers) and any leading zeros.

So, if the leading spaces are trimmed off, you need to put them back. The
question is how do you know how many spaces to add to the beginning of the
field?
 
There are three spaces as I can see. I thought that there is some option
that forces Access to keep tha spaces, thus my previous post.
I tried a different way. I imported it to Excel and than tried to import to
Access. The spaces were intact. But I don't want to do it this way. I want
to have a csv file that is bound to access, so when there is new data fiele
swaps the csv file, refreshes a pivot table in excel and they get a new
data.
And of course I want the field to be a text field as the number shall not be
used for any calculations, etc.
 
The only thing I can think of would be to use an update query to add the
spaces after you complete the import.
 
So I understand that this is normal behaviour. By why is that? I would like
to know reason for that.
 
Back
Top