Avatar billede linroc Nybegynder
30. oktober 2004 - 12:41 Der er 12 kommentarer og
1 løsning

headings på import af fastbredde textfil

Hej,

jeg sidder med en ret stor txtfil som jeg gerne vil importere til access. Det virker egentligt fint, men jeg kan ikke få headings (feltnavne) på min import.

Hvis jeg laver samme forsøg med en csv fil, så har jeg mulighed for at vælge at første linie indeholder feltnavne - men den knap kommer ikke frem ved import af fastbredde textfiler.

Lige nu kører jeg filen igennem et lille prog som laver den til csv - men jeg ville gerne undvære den arbejdsgang.

/linroc
Avatar billede terry Ekspert
30. oktober 2004 - 14:06 #1
When you import the file using the import text wizard, you can choose "First Row contains field names". You can then save the import specification for use later.
Avatar billede terry Ekspert
30. oktober 2004 - 14:10 #2
Ah, its NOT a CSV file you arte importing! I'll take a look and get back
Avatar billede terry Ekspert
30. oktober 2004 - 14:21 #3
Cant you import the file into an existing table which already has the column names?
Avatar billede linroc Nybegynder
30. oktober 2004 - 17:38 #4
The idea of importing to an already named table is not so good in this case. Tabels differ each time and contain more than 100 fields - i don't want to type them in manually :-)
Avatar billede terry Ekspert
30. oktober 2004 - 18:01 #5
When you import into a none existing table then the columns will be given a default name, can you not use these column names?
I'm not sure if it is possible otherwise. But if I find a solution then I'll get back.
Avatar billede linroc Nybegynder
30. oktober 2004 - 18:09 #6
Off course i can use the default given names - but they give no info (field1, field2....) - i would prefer to have the real names instead (and they are placed in the first line in the text file - so why not use them).

I seems strange to me that the function doesn't exists when using fixed length txtfiles - when it exists for csv files ??
Avatar billede terry Ekspert
30. oktober 2004 - 18:15 #7
Seems strange to me too, and I agree that it would be preferable to use ones own column names too.
Avatar billede terry Ekspert
31. oktober 2004 - 20:19 #8
I've had a bit of a play around with this now, and it seems that it isnt possible. If you make an import specification you can then use this in code to import files with the same layout.

EXAMPLE:
DoCmd.TransferText acImportFixed, "FixedLenImportSpec", "NewTable", "Fixed length fields test.txt", True

The last parameter SHOULD use the first line as column headers, but it still doesnt work, although it doesnt import the first line into the file.

The only alternative I can see is making the whole import in code.
Avatar billede linroc Nybegynder
01. november 2004 - 09:56 #9
Thanks for the effort terry - so I am back at square one :-)

If you post an answer I will assign the points to you.

Do you by the way know the limitations of an access db. I have an approx. 3GB pure textfile i am planning to convert into a db - but I am not sure if access can handle it. I would normally prefer to use msde for tables that size - but the textfile is formatted so i can import directly (except headings ;-) ) and here the access interface would be nice.

/linroc
Avatar billede terry Ekspert
01. november 2004 - 18:49 #10
Access is limited to 2 GB per database, and actually MSDE has that same limit (I think)  :ø(
3 Gb is a LOT of data. If it is to be split into more than one table then you could have a table in its own dB then link the tables into one.

I've posted an answer 30/10-2004 14:06:47

If I do happen to find another solution, then I'll let you know.
Avatar billede linroc Nybegynder
10. november 2004 - 08:55 #11
Thansk Terry - i didn't know the limit existed in msde (sucks) - but it seems i can handle the data as csv.

Sorry for the late asignment of points - things got just got made here :-)
Avatar billede linroc Nybegynder
10. november 2004 - 08:55 #12
accepted
Avatar billede terry Ekspert
10. november 2004 - 10:52 #13
thanks!
Microsoft introduced MSDE for free to ty and get people to go for SQL Server which costs money. Its a pitty it has a limit of 2Gb, but they obviously have to draw the line somewhere, and as its mostly used for small amounts of data and only a few users it is actually a very good alternative to Access dB's.

Once again thanks
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester