Sign in to follow this  
Followers 0
woop

txt files management.

7 posts in this topic

hello, all

first thank you to take the time to read me.

i write a script to make more clear to read the log file of the commande Subinacl.exe from the W2k ressource kit.

it work on small file but not on big file.

a big file for me is a 50Mo .txt file.

i made some test, and it work until the file size is <25Mo.

to solve that i try to make to slit the file but i don't find the good way to do that on autoit.

so any help is welcom.

my code, and after a sample of the file to process

CODE
#include <GUIConstants.au3>

#include <file.au3>

$file = "C:\Temp\test3.txt"

$log = "C:\Temp\logacl_V26122006.txt"

$serveur = "spsiv-na-don02\"

;~ Permission Valeur décimale Valeur Hexadécimale

;~ Auncun accès 2032127 1F01FF

;~ Lire 1179785 120089

;~ Ecrire 1179926 120116

;~ Exécuter 1179808 1200A0

;~ Supprimer 65536 10000

;~ Changer des permissions

;~ 262144 40000

;~ Prendre possession

;~ 524288 80000

;~ RX 1179817 1200A9

;~ Modifier 1245631 1301BF

;~ Contrôle total 2032127 1F01FF

$full = " AccessMask=0x1f01ff"

$readwrite = " AccessMask=0x1200a9"

$modifier = " AccessMask=0x1301bf"

$file_hand = FileOpen($file,0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open source file")

Exit

EndIf

$log_hand = FileOpen($log,2)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open source file")

Exit

EndIf

$nblinefichier = _FileCountLines( $file )

$rep=""

$nligne =0

$i=0

$j=0

ProgressOn("Progression", " ", "" ,"","",2 + 16)

While 1

$nligne= $nligne +1

$line = FileReadLine($file_hand)

;~ MsgBox(1,"",$line)

If @error = -1 Then ExitLoop

$line=StringReplace($line,$full,";" & "F")

$line=StringReplace($line,$readwrite,";" & "RW")

$line=StringReplace($line,$modifier ,";" & "M")

$line=StringReplace($line," Type=0x0" ,"")

$line=StringReplace($line," Flags=0x3" ,"")

$line=StringReplace($line," Flags=0x13" ,"")

$line=StringReplace($line," =" ,"")

$line=StringReplace($line, $serveur ,"")

$result = StringInStr($line, "+File")

$line=StringReplace($line,"+File ","")

if $result <>0 then

$rep = $line

Elseif $result =0 Then

$result = StringInStr($line, "/pace")

$line=StringReplace($line,"/pace" ,"")

if $result<> 0 Then

FileWriteLine($log_hand,$rep & ";" & $line)

EndIf

EndIf

If $i = 10000 then

$i=0

$j=$j+1

EndIf

If $j=100 then $j=0

ProgressSet( $j, "ligne " & $nligne & " en traitement sur " & $nblinefichier)

Wend

FileClose($file_hand)

FileClose($log_hand)

CODE

=============================

+File D:\DSIV-OM\Ace Project

=============================

/perm. ace count =20

/pace =builtin\administrators Type=0x0 Flags=0x3 AccessMask=0x1f01ff

/pace =siv\prca12751_adm2 Type=0x0 Flags=0x3 AccessMask=0x1301bf

/pace =spsiv-na-don02\zdeploiement-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zdsivom_tng-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\znsm-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_com-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_doc-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_ext_lo-p-l-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_ext_tng-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_ext-p-l-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_fact-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_info_eia-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_info-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_logist-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_micro-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_micro-p-l-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_migr-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_org-p-l-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_qualite-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_zeus-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

==========================

+File D:\DSIV-OM\commande

==========================

/perm. ace count =2

/pace =builtin\administrators Type=0x0 Flags=0x3 AccessMask=0x1f01ff

/pace =spsiv-na-don02\zrm_com-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1301bf

=====================

+File D:\DSIV-OM\ext

=====================

/perm. ace count =17

/pace =builtin\administrators Type=0x0 Flags=0x3 AccessMask=0x1f01ff

/pace =spsiv-na-don02\zdeploiement-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zdsivom_tng-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_com-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_doc-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_ext_lo-p-l-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_ext_tng-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_ext-p-l-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_fact-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_info-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1301bf

/pace =spsiv-na-don02\zrm_logist-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_micro-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1301bf

/pace =spsiv-na-don02\zrm_micro-p-l-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_migr-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_org-p-l-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_qualite-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_zeus-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

=========================

+File D:\DSIV-OM\General

=========================

/perm. ace count =5

/pace =builtin\administrators Type=0x0 Flags=0x3 AccessMask=0x1f01ff

/pace =spsiv-na-don02\zrm_com-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1301bf

/pace =spsiv-na-don02\zrm_ext-p-l-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_info-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1301bf

/pace =spsiv-na-don02\zrm_logist-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1301bf

==============================

+File D:\DSIV-OM\INFORMATIQUE

==============================

/perm. ace count =3

/pace =builtin\administrators Type=0x0 Flags=0x3 AccessMask=0x1f01ff

/pace =spsiv-na-don02\zrm_info_eia-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1200a9

/pace =spsiv-na-don02\zrm_info-p-le-l Type=0x0 Flags=0x3 AccessMask=0x1301bf

Share this post


Link to post
Share on other sites



I am not aware of a 25Mb file size restriction. What is the problem you get with files bigger than this?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

HI,

for a 50Mb file i got a empty output files.

and in try to remplace the while by for next and give you the result.

ciao. and Thank you

Try replacing the While..Wend with For..to..next:

For $value = 1 to $nblinefichier step +1
;Your script etc..
Next

Share this post


Link to post
Share on other sites

hello again,

i try to use like you tell me the for nest, with the variable $nblinefichier , but the function _FileCountLines( $file ) gibe me back a négative value like -51 383 663 Line in my file.

that look like the function can't read big file.

i will look for a new way of working !!!

ciao,

woop

Share this post


Link to post
Share on other sites

Don`t know why it`s giving a negative number...

I have used _FilecountLines for .log files which where 800Mb with more then 600.000 lines and worked..

This is giving you a negative number:

#include <file.au3>
$file = "C:\Temp\test3.txt"
$lines = _FileCountLines($file)
MsgBox(1,"Lines","Number of Lines: " & $lines)

Neo


[center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center]

Share this post


Link to post
Share on other sites

yes

$lines is set at -51 383 663 with my log file.

maby the trouble comme from my txt file, should i process it to delete some charters !!???

Don`t know why it`s giving a negative number...

I have used _FilecountLines for .log files which where 800Mb with more then 600.000 lines and worked..

This is giving you a negative number:

#include <file.au3>
$file = "C:\Temp\test3.txt"
$lines = _FileCountLines($file)
MsgBox(1,"Lines","Number of Lines: " & $lines)

Neo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0