Importing data from CSV - spaces

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
 
K

Klatuu

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?
 
I

IgorM

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.
 
K

Klatuu

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?
 
I

IgorM

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.
 
K

Klatuu

The only thing I can think of would be to use an update query to add the
spaces after you complete the import.
 
I

IgorM

So I understand that this is normal behaviour. By why is that? I would like
to know reason for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top