Subject: RE: Importing a file with 270’000 lines
In the loop, I had a counter (Integer) to count the line that the agent was reading. That was the problem. The only message I became was “Overflow”. And Kenneth give me a good way to the solution.
I paste you the code of the agent :
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim fileLine As String
Dim fileNum As Long
Dim totalAdresse As Long
Dim compteur As Long
Set db = session.CurrentDatabase
'donne le numéro de file libre pour l’importation
fileNum = Freefile
compteur = 0
'Ouvre le fichier FYBAD pour import
Open “\Saftp\Adresses_Fybad\BAN_SWIFT.txt” For Input As fileNum
Print “Début de l’importation des adresses SWIFT”
Do While Not Eof(fileNum)
'lecteur enregistrement
Line Input #fileNum, fileLine
compteur=compteur + 1
'création Adresse
Set doc = db.CreateDocument()
doc.Form="Adresse"
doc.Archive="Non"
'chargement par les valeurs lues
doc.Code_BIC=Trim(Strrightback(Strleft(fileLine,";",0,3),";"))
doc.Code_Branch=Trim(Strrightback(Strleft(fileLine,";",0,4),";"))
doc.Nom=Trim(Strrightback(Strleft(fileLine,";",0,5),";")) + Trim(Strrightback(Strleft(fileLine,";",0,6),";")) +Trim(Strrightback(Strleft(fileLine,";",0,7),";"))
doc.Localite= Trim(Strrightback(Strleft(fileLine,";",0,10),";"))
doc.Rue=Trim(Strrightback(Strleft(fileLine,";",0,14),";")) + Trim(Strrightback(Strleft(fileLine,";",0,15),";"))_
+Trim(Strrightback(Strleft(fileLine,";",0,16),";"))+Trim(Strrightback(Strleft(fileLine,";",0,17),";"))
doc.NoPostal=Trim(Strrightback(Strleft(fileLine,";",0,18),";"))
doc.Ville=Trim(Strrightback(Strleft(fileLine,";",0,19),";"))+Trim(Strrightback(Strleft(fileLine,";",0,20),";"))+Trim(Strrightback(Strleft(fileLine,";",0,21),";"))
doc.LibPays=Trim(Strrightback(Strleft(fileLine,";",0,22),";"))+Trim(Strrightback(Strleft(fileLine,";",0,23),";"))
doc.IDAdr=Trim(Strrightback(Strleft(fileLine,";",0,35),";"))
doc.TypeAdr=Trim(Strrightback(Strleft(fileLine,";",0,11),";"))
Call doc.Save(True,True)
If compteur Mod 1000 = 0 Then
Print "Nombre d'adresses importées = " + Cstr(compteur)
End If
Loop
Messagebox "ok importation terminée nb record lu : " + Cstr(compteur)
Print "ok importation terminée nb adresses créées : " + Cstr(compteur)
End Sub