hattab21 Posted October 8, 2012 Share Posted October 8, 2012 Merhaba arkadaşlar. Şirkette kullandığımız bir proğram var ve yaptığımız işlemleri txt olarak log olarak. Örneğin; 12012012.txt [quote] 12.01.2012 12:33:59 giriş yapıldı 12.01.2012 12:33:59 çıkış yapıldı [/quote] alt alta satır satır yazıyor. kaç işlem yaptığını yani kaç satır olduğunu nasıl okuyabiliriz? Quote Link to comment Share on other sites More sharing options...
blue_life Posted October 8, 2012 Share Posted October 8, 2012 @hattab21 Basit bir örnek veriyorum. Sen dosya konum bilgisini düzeltirsin! [code]Local $FILE_LOCATION = "C:\Test.txt" Local $FILE_OPEN = FileOpen($FILE_LOCATION, 0) If $FILE_OPEN = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ;Read File Local $READ_FILE = FileRead($FILE_OPEN, FileGetSize($FILE_LOCATION)) FileClose($FILE_OPEN) Local $LINE If StringInStr($READ_FILE,@LF) <> 0 Then $LINE = StringSplit($READ_FILE,@LF) Else $LINE = StringSplit($READ_FILE,@CR) EndIf MsgBox(64,"Line",$FILE_LOCATION & @Crlf & "Line = " & $LINE[0])[/code] Quote Link to comment Share on other sites More sharing options...
mesale0077 Posted October 8, 2012 Share Posted October 8, 2012 (edited) daha kısa bir yöntem daha var [CODE] #include <File.au3> Local $CountLines = _FileCountLines("C:\Test.txt") MsgBox(4160, "Bilgi", "Bu dosyada " & $CountLines & " adet satır var") Exit [/CODE] Edited October 8, 2012 by mesale0077 Quote Link to comment Share on other sites More sharing options...
DivaneTR Posted October 20, 2012 Share Posted October 20, 2012 [font=tahoma,geneva,sans-serif]Kütüphanedeki tüm fonksyionları include ettikten sonra emin ol daha uzun oluyor, yöntem kısa ama kodlar uzun. Ha /striponly parametresiyle derlerse sıkıntı yok.[/font] Quote Link to comment Share on other sites More sharing options...
mesale0077 Posted October 20, 2012 Share Posted October 20, 2012 evet dediğin gibi kısa gözüksede gerçekten kod uzunmuş yazdığı kod örneği için ,blue_life arkadaşımızı tekrar burdan tebrik ediyorum ayrıca konu hakkında bilgilendirme yaptığınız içinde sağolun Quote Link to comment Share on other sites More sharing options...
radyofon Posted October 22, 2012 Share Posted October 22, 2012 blue_life üstadıma teşekkürler. Aynı zamanda String komutlarının nasıl kullanılabileceğine iyi bir örnek olmuş. Quote Link to comment Share on other sites More sharing options...
justpl4y Posted April 14, 2014 Share Posted April 14, 2014 Eski konuyu hortlatmış oluyorum ama benzer bir log için satırda belirli bir alanı değiştirmem gerekiyor. Log "11 12.01.2012 12:33:59" şeklinde, 11 kullanıcı kodunu belirtiyor. Her kullanıcı için farklı bir kod veriyor log fakat isimleri numaralarla eşleştirmek uzun zaman alıyor. Satırda sadece kullanıcı kodu olan kısmı nasıl değiştirebilirim? Atıyorum 11 = Ahmet, 01 = mehmet vs.. Quote Link to comment Share on other sites More sharing options...
MostWanted Posted April 14, 2014 Share Posted April 14, 2014 11'in ahmet olduğu nerde yazıyor peki? Quote Link to comment Share on other sites More sharing options...
justpl4y Posted April 15, 2014 Share Posted April 15, 2014 (edited) İşte kart basınca sadece kullanıcının kodunu ekliyor loga, 11le ahmeti eşleştiricem bir şekilde, onu öyle böyle hallederim de satırın belirli bir yerini nasıl değiştirebilirim onu bulamadım. c# için örnek var aslında bir yerlerde olmadı onu kurcalıycam bakalım. Edited April 15, 2014 by justpl4y Quote Link to comment Share on other sites More sharing options...
radyofon Posted April 16, 2014 Share Posted April 16, 2014 $text = StringReplace($READ_FILE, "11", "Ahmet") Local $numreplacements = @extended MsgBox(0, "Yeni satır", $text) blue_life üstadımın kodlarının altına bu kodu eklemelisiniz. Quote Link to comment Share on other sites More sharing options...
MostWanted Posted April 18, 2014 Share Posted April 18, 2014 @radyofon Kodu eğer öyle yazarsak bu sefer sadece baştaki 11 değil bütün 11 ler yani tarihlerdeki ve saattekiler de değişecektir.O yüzden pek güzel bi çözüm olmasa gerek.Ben şöyle bi çözüm sundum umarım anlaşılırdır. $dosyan = "Dosya yolunu gir" Local $txtlines = FileReadToArray($dosyan) If @error Then MsgBox(0,"", "Hata!Dosya okunamadı!") Else For $i = 0 To UBound($txtlines) - 1 $usernumber = StringSplit($txtlines[$i]," ")[1] ; kullanıcı numarası bu ;datayı aldığını nerden söylemediğin için şöyle uydurma bi kod koyuyorum $username = ""; Switch Number($usernumber) Case 11 $username = "Ahmet" Case 12 $username = "Mehmet" EndSwitch $txtlines[$i] = StringReplace($txtlines[$i],$usernumber, $username, 1) Next EndIf For $i = 0 To UBound($txtlines) - 1 FileWriteLine($dosyan, $txtlines[$i]) Next Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.