Das Notes Forum
Domino 9 und frühere Versionen => Administration & Userprobleme => Thema gestartet von: nafets1001 am 24.06.02 - 18:20:58
-
Hallo,
ich möchte gerne eine strukturierte Textdatei in Notes über einen Agenten importieren lassen.
Ein manueller import funtioniert.
Wie muß ich das anstellen?
Vielen Dank
Stefan G.
-
Strukturiert hesst bei dir was ??
1. Datensatz
Feld 1
Feld 2
2. Datensatz
Feld 1
Feld2
oder meinst du mit Trennzeichen ??
eknori
-
Hallo,
ich habe eine textdatei die wie folgt aufgeteilt ist.
1111,2222,3333,4444,5555,6666
wobei die einzelnen zellen unterschiedliche längen und unterschiedliche Formate haben.
Wie oben zu sehen ist sind alle Zellen durch komma getrennt.
Für den manuellen import benutze ich eine Formatdatei:
Feldname type text until ",", usw.
Vielen Dank für die schnalle Antwort.
Stefan G.
-
Hab hier ein bbisschen LS Code; musst du nur noch an deine Erfordernisse anpassen
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
' Dim recList List As cdmsRec
' Dim tempRec As cdmsRec
Dim linestr As String
Dim linearray () As String
Dim vararray (1 To 6) As String 'The array should be dimensioned to have as many elements as
there are separate fields on each record you're importing
Set db = session.CurrentDatabase
Dim collection As NotesDocumentCollection
Set collection = db.AllDocuments
If Not (db.IsFTIndexed) Then
Call db.UpdateFTIndex(True)
End If
Call collection.FTSearch("phone", 0)
If collection.Count <> 0 Then
Call collection.RemoveAll(True)
End If
filenum% = Freefile () ' Find the first free file number available
Open "C:\phones.txt" For Input As filenum% ' Open the file to be imported, identifying it with the
file number found above
recNum% = 1 ' For each line of the file, read that line into an array element of linearray
Do While Not Eof (filenum%)
Redim Preserve linearray (recnum%)
Line Input #fileNum%, linestr
linearray (recNum%) = "% " + linestr + "%"
recNum% = recNum% + 1
Loop
Close #fileNum%
For y = 1 To Ubound(linearray) ' This will loop through each element of linearray, which is each
record in the original file
' For each record, parse the individual fields out into an array. Since there are 38 fields in the file,
loop through 38 times
position1% = 1
For x = 1 To 6
'position1% is the position of the first tilde and position2% is the second tilde. What's between is a
field value
position2% = Instr(position1% + 1, linearray(y), "%")
vararray (x) = Mid$ (linearray (y), position1% + 1, (position2% - position1%) - 1)
position1% = position2%
Next
Set doc = New NotesDocument (db) ' Create a new document, setting each field to an element of
the vararray
doc.Form = "phone"
doc.LName = vararray (1)
doc.FName = vararray (2)
doc.Ext = vararray (3)
doc.Loc = vararray (4)
doc.DeptNum = vararray (5)
doc.Dept = vararray (6)
doc.ImportFlag = "Import"
Call doc.Save (True, True)
Next
Call db.UpdateFTIndex(True)
End Sub
-
Hallo,
ich habe den LS Code eingefügt.
Ohne das ich diesen anpasse bekomme ich angezeigt, das darin 4 Fehler sind.
Angepasst habe ich:
1.
Dim vararray (1 To 6) As String 'The array should be dimensioned to have as many elements as
there are separate fields on each record you're importing
--> in (1 To 8) da meine datei nur 8 Felder hat
2.
Call collection.FTSearch("phone", 0)
--> phone geändert in meine maske gewählt
3.
Open "C:\text123.txt" For Input As filenum% ' Open the file to be imported, identifying it with the
file number found above
--> Datei die importiert werden soll
4.
' For each record, parse the individual fields out into an array. Since there are 6 fields in the file,
loop through 6 times
position1% = 1
For x = 1 To 6
--> hier ernewut an meine datenfelder =8 angepasst
5.
doc.Form = "dateneingabe"
doc.datum = vararray (1) usw.
--> hier meinen maskennamen und meine vararrays angegen zusätzlich nummer (7) und 8 mit angegeben
Wo liegt mein Fehler ?
Vielen Dank
Stefan G.