Batch Index du Forum
S’enregistrerRechercherFAQMembresGroupesConnexion
Répondre au sujet Page 1 sur 1
[?] Chercher et compter des occurances dans un fichier
Auteur Message
Répondre en citant
Message [?] Chercher et compter des occurances dans un fichier 
Bonjour à tous

j'ai besoin d'un coup de main ou de pistes.

J'ai un fichier JSON dans lequel je dois compter des occurances

C'est cette partie qui m'intéresse

Code:

"Profile 1": {
"avatar_icon": "chrome://theme/IDR_PROFILE_AVATAR_15",
"background_apps": false,
"name": "Laddy",
"use_gaia_picture": false,
"user_name": "" ; demander l adresse mail si existant
}
},
"Profile 2": {
"avatar_icon": "chrome://theme/IDR_PROFILE_AVATAR_15",
"background_apps": false,
"name": "Toto",
"use_gaia_picture": false,
"user_name": "" }
},

Il faudrait que je puisse compter le nombre de profile contenu dans ce fichier à partir de Profile 1.
et obtenir le bon numéro du profil suivant dans une variable

Code:

Func $ComptProfiles()
;?????
Local $fC = Local
Local $nBuf = FileRead($fC) ; je bloque ici

$Comp_Users += 1
$Profil_Users = "Profile "&$Comp_Users
EndFunc

ConsoleWrite($Profil_Users)



Code:
"Profile X": {
"avatar_icon": "chrome://theme/IDR_PROFILE_AVATAR_15",
"background_apps": false,
"name": "",
"use_gaia_picture": false,
"user_name": ""
}
},


Si quelqu'un a une idée. ça serait hyper sympa.


Code:

{
"background_mode": {
"enabled": false
},
"background_pages": {
"known": {
"ajpgkpeckebdhofmmjfgcjjiiejpodla": false,
"apebebenniibdlpbookhgelaghfnaonp": false,
"cfhdojbkjhnklbpkdaibdccddilifddb": false
}
},
"browser": {
"clear_lso_data_enabled": true,
"hung_plugin_detect_freq": 2000,
"last_known_google_url": "http://www.google.ch/",
"last_prompted_google_url": "http://www.google.ch/",
"last_redirect_origin": "",
"plugin_message_response_timeout": 30000
},
"gpu_blacklist": {
"entries": [ {
"blacklist": [ "webgl" ],
"description": "ATI Radeon X1900 is not compatible with WebGL on the Mac.",
"device_id": [ "0x7249" ],
"id": 1,
"os": {
"type": "macosx"
},
"vendor_id": "0x1002",
"webkit_bugs": [ 47028 ]
}, {
"blacklist": [ "accelerated_compositing" ],
"cr_bugs": [ 59302 ],
"description": "GL driver is software rendered. Accelerated compositing is disabled.",
"gl_renderer": {
"op": "contains",
"value": "software"
},
"id": 3,
"os": {
"type": "linux"
}
}, {
"blacklist": [ "webgl" ],
"description": "The Intel Mobile 945 Express family of chipsets is not compatible with WebGL.",
"device_id": [ "0x27AE" ],
"id": 4,
"os": {
"type": "any"
},
"vendor_id": "0x8086"
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 71381, 76428, 73910, 101225 ],
"description": "ATI/AMD cards with older or third-party drivers in Linux are crash-prone.",
"exceptions": [ {
"driver_vendor": {
"op": "contains",
"value": "AMD"
},
"driver_version": {
"number": "8.92",
"op": "\u003E="
}
} ],
"id": 5,
"os": {
"type": "linux"
},
"vendor_id": "0x1002"
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 72938 ],
"description": "NVIDIA GeForce FX Go5200 is assumed to be buggy.",
"device_id": [ "0x0324" ],
"id": 8,
"os": {
"type": "any"
},
"vendor_id": "0x10de"
}, {
"blacklist": [ "webgl" ],
"cr_bugs": [ 73794 ],
"description": "NVIDIA GeForce 7300 GT on Mac does not support WebGL.",
"device_id": [ "0x0393" ],
"id": 10,
"os": {
"type": "macosx"
},
"vendor_id": "0x10de"
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 72979, 89802 ],
"description": "Drivers older than 2009-01 on Windows are assumed to be buggy.",
"driver_date": {
"number": "2009.1",
"op": "\u003C"
},
"exceptions": [ {
"device_id": [ "0x29a2" ],
"driver_version": {
"number": "7.15.10.1624",
"op": "\u003E="
},
"vendor_id": "0x8086"
} ],
"id": 12,
"os": {
"type": "win"
}
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 74212 ],
"description": "ATI drivers older than 10.6 on Windows XP are assumed to be buggy.",
"driver_version": {
"number": "8.741",
"op": "\u003C"
},
"id": 13,
"os": {
"type": "win",
"version": {
"number": "5",
"op": "="
}
},
"vendor_id": "0x1002"
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 74212 ],
"description": "NVIDIA drivers older than 257.21 on Windows XP are assumed to be buggy.",
"driver_version": {
"number": "6.14.12.5721",
"op": "\u003C"
},
"id": 14,
"os": {
"type": "win",
"version": {
"number": "5",
"op": "="
}
},
"vendor_id": "0x10de"
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 74212 ],
"description": "Intel drivers older than 14.42.7.5294 on Windows XP are assumed to be buggy.",
"driver_version": {
"number": "6.14.10.5294",
"op": "\u003C"
},
"id": 15,
"os": {
"type": "win",
"version": {
"number": "5",
"op": "="
}
},
"vendor_id": "0x8086"
}, {
"blacklist": [ "multisampling" ],
"cr_bugs": [ 67752, 83153 ],
"description": "Multisampling is buggy in some ATI Mac cards.",
"exceptions": [ {
"device_id": [ "0x6760", "0x9488" ]
} ],
"id": 16,
"os": {
"type": "macosx"
},
"vendor_id": "0x1002"
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 76703 ],
"description": "Intel mesa drivers are crash-prone.",
"id": 17,
"os": {
"type": "linux"
},
"vendor_id": "0x8086"
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 84701 ],
"description": "NVIDIA Quadro FX 1500 is buggy.",
"device_id": [ "0x029e" ],
"id": 18,
"os": {
"type": "linux"
},
"vendor_id": "0x10de"
}, {
"blacklist": [ "accelerated_2d_canvas", "accelerated_compositing" ],
"cr_bugs": [ 87157 ],
"description": "Accelerated 2d canvas and accelerated compositing are not supported in Mac OSX version 10.5.",
"id": 19,
"os": {
"type": "macosx",
"version": {
"number": "10.5",
"op": "="
}
}
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 82232, 82541 ],
"description": "NVIDIA driver 260.19.06 on linux is crash-prone.",
"driver_vendor": {
"op": "=",
"value": "NVIDIA"
},
"driver_version": {
"number": "260.19.6",
"op": "="
},
"id": 20,
"os": {
"type": "linux"
},
"vendor_id": "0x10de"
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 87680, 90091 ],
"description": "NVIDIA driver 195.36.24 on linux is buggy for certain Quadro FX series cards.",
"device_id": [ "0x00cd", "0x00ce" ],
"driver_vendor": {
"op": "=",
"value": "NVIDIA"
},
"driver_version": {
"number": "195.36.24",
"op": "="
},
"id": 21,
"os": {
"type": "linux"
},
"vendor_id": "0x10de"
}, {
"blacklist": [ "all" ],
"description": "NVIDIA linux drivers older than 195.36.24 are assumed to be buggy.",
"driver_vendor": {
"op": "=",
"value": "NVIDIA"
},
"driver_version": {
"number": "195.36.24",
"op": "\u003C"
},
"id": 22,
"os": {
"type": "linux"
},
"vendor_id": "0x10de"
}, {
"blacklist": [ "all" ],
"description": "Mesa drivers in linux older than 7.11 are assumed to be buggy.",
"driver_vendor": {
"op": "=",
"value": "Mesa"
},
"driver_version": {
"number": "7.11",
"op": "\u003C"
},
"id": 23,
"os": {
"type": "linux"
}
}, {
"blacklist": [ "accelerated_2d_canvas" ],
"description": "Accelerated 2d canvas is unstable in Linux at the moment.",
"id": 24,
"os": {
"type": "linux"
}
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 95934, 94973 ],
"description": "ATI/AMD cards with older drivers in Linux are crash-prone.",
"exceptions": [ {
"driver_vendor": {
"op": "contains",
"value": "AMD"
},
"driver_version": {
"number": "8.92",
"op": "\u003E="
}
} ],
"gl_vendor": {
"op": "beginwith",
"value": "ATI"
},
"id": 27,
"os": {
"type": "linux"
}
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 95934, 94973 ],
"description": "ATI/AMD cards with third-party drivers in Linux are crash-prone.",
"gl_renderer": {
"op": "contains",
"value": "AMD"
},
"gl_vendor": {
"op": "beginwith",
"value": "X.Org"
},
"id": 28,
"os": {
"type": "linux"
}
}, {
"blacklist": [ "all" ],
"cr_bugs": [ 95934, 94973 ],
"description": "ATI/AMD cards with third-party drivers in Linux are crash-prone.",
"gl_renderer": {
"op": "contains",
"value": "ATI"
},
"gl_vendor": {
"op": "beginwith",
"value": "X.Org"
},
"id": 29,
"os": {
"type": "linux"
}
} ],
"name": "software rendering list",
"version": "1.22"
},
"gpu_blacklist_update": "1324641815.555545",
"intl": {
"app_locale": "fr"
},
"local_state": {
"multiple_profile_prefs_version": 3
},
"ntp": {
"intro_display_count": 11,
"promo_locale": "fr",
"promo_version": 7,
"webstore_enabled": false
},
"printing": {
"print_preview_enabled_once": true
},
"profile": {
"info_cache": {
"Default": {
"avatar_icon": "chrome://theme/IDR_PROFILE_AVATAR_13",
"background_apps": true,
"name": "Laddy",
"use_gaia_picture": false,
"user_name": ""
},
"Profile 1": {
"avatar_icon": "chrome://theme/IDR_PROFILE_AVATAR_19",
"background_apps": false,
"name": "Toto",
"use_gaia_picture": false,
"user_name": ""
},
"Profile 2": {
"avatar_icon": "chrome://theme/IDR_PROFILE_AVATAR_15",
"background_apps": false,
"name": "M\u00E9m\u00E8re",
"use_gaia_picture": false,
"user_name": ""
}
},
"last_used": "Default",
"profiles_created": 3
},
"protocol_handler": {
"excluded_schemes": {
"afp": true,
"data": true,
"disk": true,
"disks": true,
"file": true,
"hcp": true,
"javascript": true,
"mailto": false,
"ms-help": true,
"news": false,
"nntp": true,
"shell": true,
"snews": false,
"vbscript": true,
"view-source": true,
"vnd": {
"ms": {
"radio": true
}
}
}
},
"safe_browsing": {
"client_key": "g-KRqL2tbehzdpwuFnCuPA==",
"wrapped_key": "AKEgNitnO68xLaTd3Qtk6bNe10SYmUn8F8nTxUBSEHzkSHxb8IJW8N6ZPrTDCudiuYFoHrIjE5qFNvQDHARqW6ofg8kvqf0lAQ=="
},
"show-minimal-first-run-bubble": true,
"shutdown": {
"num_processes": 0,
"num_processes_slow": 0,
"type": 0
},
"task_manager": {
"window_placement": {
"bottom": 434,
"left": 277,
"maximized": false,
"right": 747,
"top": 136,
"work_area_bottom": 570,
"work_area_left": 0,
"work_area_right": 1024,
"work_area_top": 0
}
},
"uninstall_metrics": {
"installation_date2": "1307281683",
"launch_count": "257"
},
"user_experience_metrics": {
"session_id": 256,
"stability": {
"breakpad_registration_fail": 0,
"breakpad_registration_ok": 1,
"crash_count": 0,
"debugger_not_present": 1,
"debugger_present": 0,
"exited_cleanly": true,
"incomplete_session_end_count": 0,
"last_timestamp_sec": "1332334664",
"launch_count": 1,
"launch_time_sec": "1332334592",
"page_load_count": 0,
"renderer_crash_count": 0,
"renderer_hang_count": 0,
"session_end_completed": true,
"stats_buildtime": "1332180828",
"stats_version": "18.0.1025.116"
}
},
"was": {
"restarted": false
}
}








______________________________________________________
Faites paraitre votre batch sur BatchClipboard
Visiter le site web du posteur
Message Publicité 
PublicitéSupprimer les publicités ?


Répondre en citant
Message [?] Chercher et compter des occurances dans un fichier 
Salut,

je vais me pencher sur la question si tu test mon système antivol Mr. Green

/déconne off

dès que j'ai une peu de temps je regarde ce que je peux faire.

EDIT: premier jet, dis moi si sa t'aide
Code:

$read = FileRead("test.txt")
$line = StringSplit($read,@CRLF)
$i2 = 0
for $i = 1 to $line[0]
   $var = StringInStr($line[$i],'"Profile ')
   if $var <> 0 Then
      $i2 += 1
      msgbox(0,$i2,$line[$i] & @CRLF & $line[$i+2] & @CRLF & $line[$i+4] & @CRLF & $line[$i+6] & @CRLF & $line[$i+8] & @CRLF & $line[$i+10])
   EndIf
Next


EDIT : deuxième jet, dis-moi encore si sa t'aide ^^
Code:

$read = FileRead("test.txt")
$line = StringSplit($read,@CRLF)
global $tab[100][100],$i2
for $i = 1 to $line[0]
   $var = StringInStr($line[$i],'"Profile ')
   if $var <> 0 Then
      $i2 += 1
      $tab[$i2][1] = _adapt($line[$i+2])
      $tab[$i2][2] = _adapt($line[$i+4])
      $tab[$i2][3] = _adapt($line[$i+6])
      $tab[$i2][4] = _adapt($line[$i+8])
      $tab[$i2][5] = _adapt($line[$i+10])
      msgbox(0,$i2,$line[$i] & @CRLF & $tab[$i2][1] & @CRLF & $tab[$i2][2] & @CRLF & $tab[$i2][3] & @CRLF & $tab[$i2][4] & @CRLF & $tab[$i2][5])
   EndIf
Next

func _adapt($var)
   $var2 = ""
   if StringInStr($var,'"name"') <> 0 then $var2 = "Nom: "
   if StringInStr($var,'"user_name"') <> 0 then $var2 = "Nom d'utilisateur: "
   if StringInStr($var,'"avatar_icon"') <> 0 then $var2 = "Icône de l'avatar: "
   $var = StringRight($var,StringLen($var)-StringInStr($var,":"))
   if $var = " false," then $var = "False"
   if $var = " true," then $var = "True"
   $var = StringReplace($var,'",',"")
   $var = StringReplace($var,'"',"")
   if $var = " " then $var = "Valeur Null"
   return $var2 & $var
EndFunc




Dernière édition par Cαutex le Mar 10 Avr 2012 - 17:11; édité 1 fois

______________________________________________________
Mes principales réalisations: Cp (batch) et IPSvc (autoit)
Répondre en citant
Message [?] Chercher et compter des occurances dans un fichier 
ça m'aide super cmanix, faut que je regarde encore pour faire des tests à midi.
Surtout que la 2eme code semble me donnait la possibilité d'exploiter chaque ligne du profil chose que je vais avoir besoin ;D
Pour la suite Very Happy

Edit : J'ai testé dans mon train ton code Very Happy dis moi comment faire pour avoir le total des profils trouvés ?

$i2 compte bien les profils trouvés et il me faudrait le total pour pouvoir l'augmenter de 1 afin de créer un nouveau nom de profil
ou alors une idée

"profiles_created": 3 -> faire 3-1 (à cause de default) puis +1


Je veux bien tester ton programme mais je ne comprend pas son fonctionnement Embarassed




______________________________________________________
Faites paraitre votre batch sur BatchClipboard
Visiter le site web du posteur
Répondre en citant
Message [?] Chercher et compter des occurances dans un fichier 
J'ai l'impression que tu te prend la tête pour rien; pourquoi tu ne créé pas une variable (ex: $total_profiles = $i2) comme sa tu récupère le nombre de profil réel et tu ne modifie pas la variable $i2 (même si je ne vois pas de problème à la modifier directement).




______________________________________________________
Mes principales réalisations: Cp (batch) et IPSvc (autoit)
Répondre en citant
Message [?] Chercher et compter des occurances dans un fichier 
Je vais voir ça merci cmanix.

Après va falloir que je trouve la fin du dernier profile pour ajouter le prochain lol compliquer cette nouvelle version de chrome.




______________________________________________________
Faites paraitre votre batch sur BatchClipboard
Visiter le site web du posteur
Message [?] Chercher et compter des occurances dans un fichier 


Montrer les messages depuis:
Répondre au sujet Page 1 sur 1
  



Index | créer un forum | Forum gratuit d’entraide | Annuaire des forums gratuits | Signaler une violation | Conditions générales d'utilisation
Copyright 2008 - 2016 // Batch