25. november 2011 - 23:14
Der er
13 kommentarer og 1 løsning
TXT import
Hej Jeg prøver at importere en TXT fil til access. Filen består af en masse tal adskilt med | Men i hver linie er der lavet et linje skift, dette ødelægger min import. Er der en måde at importere, så access ignorer linieskift ? MVH Tony
Annonceindlæg fra Cognizant
26. november 2011 - 11:48
#1
when you import a text file it is possible to press the "advancded" button where get much more control over the import process. I wouldnt have thought that a new line would give any problmes.
26. november 2011 - 11:49
#2
You can also save the import specification for later use
26. november 2011 - 19:49
#3
Hi terry As I see it, I cannot use the advance import settings (access 2003), and I cannot save the process. If I make and import, the line break, also make a line break in the table, so the data is no longere in the right collum. I need to use a macro or a vba code, because it has to be used serveral times a day by different users. Regards Tony
27. november 2011 - 09:55
#4
Hi Tony Can you send me an example of the file? ekspertenATsanthell.dk AT = @
28. november 2011 - 16:19
#5
Når jeg får sådanne data plejer jeg at hive filen igennem PHP først hvor jeg printer hver linje og indsætter linjeskift. Så copy/paster jeg resultatet fra min browser over i en ny TXT... quick and dirty, men det spiller fint med flere hundrede tusinde records... Alternativt skal du i VBA og gøre noget tilsvarende efter importen.
29. november 2011 - 08:44
#6
Hej Tingholm Jeg skal bruge en automatisk import, der er flere bruger, så det skal foregå uden en masse procedurer. VBA er fint, men jeg er ikke skarp i VBA. Er der nogen der måske kan hjælpe mig på vej ? MVH Tony
30. november 2011 - 20:06
#7
Hej Jeg har prøvet denne: Private Sub Kommandoknap1_Click() DoCmd.TransferText acImportDelim, test, "tbltxtload", "C:\test.txt", True End Sub Jeg har levet importspecifikationer ved navn test, der separere tekst ved hjælp af |. Men kode bruger ikke importspecifikationerne. Hvad gør jeg forkert ? MVH Tony
30. november 2011 - 21:31
#8
put test in a string "test"
01. december 2011 - 09:15
#9
Hi Terry Much better tks. Er der nogen der ved hvordan jeg kan undgå, at importere linie skift i denne import: Private Sub Kommandoknap1_Click() DoCmd.TransferText acImportDelim, "test", "tbltxtload", "C:\test.txt", True End Sub MVH Tony
01. december 2011 - 19:08
#10
Hi Tony The line (extra) break (in the middle of the line) is the source of the problem Access doesnt know that the extra line break is not supposed to be there so it assumes that its teh end of the record and thats why you get extra (short) records. So it will need to be removed in code which can also be a challenge
02. december 2011 - 08:23
#11
Hi Terry Could it be possible to set the separator, for 2 signs. So access see both | and linebreak as a separator ? Each line ends with a þ , this should be set as a linebreak. Regards Tony
04. december 2011 - 10:42
#12
No I very much doubt you can have two seperators. The way I see it is you will need to read the file first remove ALL CR/LF characters and then convert þ to CR/LF I still can not understand that SAP expects a CR/LF in the middle of teh line and at the same time uses it as EOL
08. december 2011 - 09:26
#13
Hej Er der nogen der hjæple mig videre med denne convert fil ? Sub Convert_data() Const ForReading = 1 Const ForWriting = 2 Dim Infile Dim Outfile Infile = "C\test.txt" Outfile = "C\converted.txt" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(Infile, ForReading) ....remove linebreak ALL CR/LF...... ....convert þ to CR/LF..... Next objFile.Close End Sub
11. december 2011 - 12:50
#14
Prøver på ny MVH Tony
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser