cs_maya77
Messages postés36Date d'inscriptionvendredi 13 novembre 2009StatutMembreDernière intervention18 juin 2011
-
16 juin 2011 à 15:22
cs_maya77
Messages postés36Date d'inscriptionvendredi 13 novembre 2009StatutMembreDernière intervention18 juin 2011
-
18 juin 2011 à 13:43
Bonjour,
j'ai deux fichiers identiques, l'un est complet et l'autre où il manque quelques chaînes de caractères. Je voudrai créer des vecteurs de telle sorte que quand les chaînes sont identiques on insert dans un fichier résultat un +1 suivie de cette même chaîne, et dans le cas où une chaîne n'est pas contenu dans le second fichier, l'insérer avec un -1 avant.
Voici mon code mais mon fichier résultat atteint 4go ce qui est impossible:
Dim sr As New StreamReader("C:\Users\...\fichier.txt")
Dim contains As String = sr.ReadToEnd
Dim tab() As String = contains.Split(" ")
Dim res As String
Dim res1 As String
Dim path1 As String = "C:\Users\..." & i & "fichier2.txt"
Dim sr2 As New StreamReader(path1, Encoding.UTF8)
Dim container As String = sr2.ReadToEnd
Dim tab1() As String = container.Split(" ")
Dim sw As StreamWriter = New StreamWriter("C:\Users\......\resultat.txt")
Dim v As Integer = 0
Dim w As Integer = 0
While v < UBound(tab) 'And w < UBound(tab1)
If tab(v) = tab1(w) Then
Dim empl As Long = InStr(tab(v), "/")
res &= vbCrLf & "+1 " & (Mid(tab(v), empl + 1) + Chr(32))
sw.WriteLine(res)
If v < UBound(tab) Then
v = v + 1
End If
If w < UBound(tab1) Then
w = w + 1
End If
While tab(v) = tab1(w)
Dim empl2 As Long = InStr(tab(v), "/")
res &= Mid(tab(v), empl2 + 1) + Chr(32)
sw.WriteLine(res)
If v < UBound(tab) Then
v = v + 1
End If
If w < UBound(tab1) Then
w = w + 1
End If
End While
Else
Dim empl As Long = InStr(tab(v), "/")
res1 &= vbCrLf & "-1 " & Mid(tab(v), empl + 1) + Chr(32)
sw.WriteLine(res1)
If v < UBound(tab) Then
v = v + 1
End If
While tab(v) <> tab1(w)
Dim empl1 As Long = InStr(tab(v), "/")
res1 &= Mid(tab(v), empl1 + 1) + Chr(32)
sw.WriteLine(res1)
If v < UBound(tab) Then
v = v + 1
End If
End While
End If
End While
sr.Close()
sr2.Close()
sw.Close()