Parser un fichier texte contenant des blocs de données
cs_Tioneb
Messages postés193Date d'inscriptiondimanche 16 décembre 2001StatutMembreDernière intervention29 juillet 2015
-
29 juil. 2015 à 13:37
Titouaix
Messages postés7Date d'inscriptionvendredi 13 décembre 2013StatutMembreDernière intervention20 décembre 2017
-
7 août 2015 à 18:15
Bonjour,
Je cherche à parser un fichier de sauvegarde d'un jeu pour pouvoir manipuler ce qu'il contient. Il s'agit d'un fichier texte contenant des couples "Variable Valeur" et des blocs imbriqués.
Mon problème c'est que je ne sais pas comment traiter ces données. Je ne peux pas le faire ligne par ligne puisqu'il y a des blocs et je ne vois pas comment faire pour traiter par bloc justement. Si quelqu'un a une idée...
Merci d'avance
Voici un exemple de contenu:
Version alpha-34a NumCellsX 150 NumCellsY 120 OriginX 0 OriginY 0 OriginW 150 OriginH 120 TimeIndex 9653.6162684056908 TimeWarpFactor 0.7500000 RandomSeed 19539 SecondsPlayed 7739 Reoffend 23 ObjectId.next 7736826 EnabledElectricity true EnabledWater true EnabledFood true EnabledMisconduct true EnabledGangs true EnabledDecay true EnabledVisibility true ObjectsCentreAligned true FoodQuantity 1 FoodVariation 1 BioVersions 4 BEGIN Cells BEGIN "0 0" Mat PavingStone Con 0.0000000 END BEGIN "0 1" Con 0.0000000 END BEGIN "0 2" Con 0.0000000 END BEGIN "1 0" Mat PavingStone Con 0.0000000 END BEGIN "1 1" Mat PavingStone Con 0.0000000 END BEGIN "1 21" Mat Grass Con 0.0000000 END BEGIN "1 22" Mat PavingStone Con 0.0000000 END BEGIN "1 23" Con 0.0000000 END END BEGIN Objects Size 835 BEGIN "[i 0]" Id.i 0 Id.u 7666758 Type Tree SubType 2 Pos.x 1.477539 Pos.y 21.79163 Age 7200.000 END BEGIN "[i 1]" Id.i 1 Id.u 7666759 Type Tree SubType 2 Pos.x 3.972595 Pos.y 14.41187 Age 7200.000 END BEGIN "[i 101]" Id.i 101 Id.u 7690667 Type Chair SubType 0 Pos.x 113.5000 Pos.y 72.50000 END BEGIN "[i 102]" Id.i 102 Id.u 7670300 Type StaffDoor SubType 0 Pos.x 121.5000 Pos.y 82.50000 Or.x -1.000000 Or.y -4.371139e-008 OpenDir.x 0 SectorTimer 55.21328 CellIdTimer 55.21328 END BEGIN "[i 144]" Id.i 144 Id.u 7666902 Type Tree SubType 5 Pos.x 90.57959 Pos.y 27.00800 Age 7200.000 END BEGIN "[i 145]" Id.i 145 Id.u 7684835 Type VisitorTable SubType 0 Pos.x 117.0000 Pos.y 109.5000 Or.x -1.000000 Or.y -4.371139e-008 Name Grant_Visitation_Room_VisitorTable Timer 0.5996739 END BEGIN "[i 146]" Id.i 146 Id.u 7684893 Type MetalDetector SubType 0 Pos.x 117.5000 Pos.y 117.5000 Or.x -1.000000 Or.y -4.371139e-008 Walls.y 1.000000 Name Grant_Visitation_Room_MetalDetector Powered true On true END BEGIN "[i 147]" Id.i 147 Id.u 7684197 Type JailDoor SubType 0 Pos.x 117.5000 Pos.y 55.50000 Or.x -1.000000 Or.y -4.371139e-008 CloseTimer 2.983443 OpenDir.x 0 Open 1.000000 SectorTimer 54.97972 CellId.i 21 CellId.u 7682009 CellIdTimer 54.97972 END BEGIN "[i 163]" Id.i 163 Id.u 7675700 Type Light SubType 0 Pos.x 116.5000 Pos.y 108.5000 Name Grant_Visitation_Room_Light Powered true On true END BEGIN "[i 164]" Id.i 164 Id.u 7683384 Type Guard SubType 1 Pos.x 115.3245 Pos.y 65.46770 Or.x -0.9999490 Or.y -0.01136312 Vel.x -0.3656195 Vel.y -0.004154789 Dest.x 112.5000 Dest.y 65.50000 Equipment Baton Energy 26.61951 Station.i 59 Station.u 0 Timer 2.376362 Patrol.LastPos.x 116 Patrol.LastPos.y 43 Patrol.ThisPos.x 117 Patrol.ThisPos.y 43 END
END BEGIN Rooms Size 66 BEGIN "[i 0]" Id.i 0 Id.u 7668548 RoomType Intake Name Intake END BEGIN "[i 62]" Id.i 62 Id.u 7710117 RoomType MedicalWard Name Grant_Health_Ward END BEGIN "[i 63]" Id.i 63 Id.u 7715201 RoomType Classroom Name Grant_EducationReformProgram_Classroom END BEGIN "[i 64]" Id.i 64 Id.u 7722090 RoomType Chapel Name Chapel END BEGIN "[i 65]" Id.i 65 Id.u 7722777 RoomType CleaningCupboard Name CleaningCupboard END END BEGIN Mods BEGIN Mod Name "CCTV Camera Arrows" FileID F437608858 END BEGIN Mod Name "Reset Button v.31" FileID F333776634 END BEGIN Mod Name "add bars wall/jail panels" FileID F322280746 END BEGIN Mod Name "More calls" FileID F325843848 END BEGIN Mod Name "French (Alpha 30)" FileID F401246082 END END BEGIN WorkQ Next 12130 BEGIN Items Size 396 BEGIN "[i 0]" Id 11500 Type InstallObject CellX 119 CellY 29 Orientation.x 8.742278e-008 Orientation.y -1.000000 ObjType Window WorkTotal 3.000000 ObjAssigned.i 793 ObjAssigned.u 7733092 END BEGIN "[i 391]" Id 12095 Type InstallObject CellX 82 CellY 59 ObjType JailDoorLarge WorkTotal 7.000000 ObjAssigned.i 775 ObjAssigned.u 7736570 END BEGIN "[i 392]" Id 12109 Type ImproveCellIndoor CellX 107 CellY 33 InProg true WorkTotal 1.000000 END BEGIN "[i 393]" Id 12127 Type StoreObject CellX 128 CellY 74 HighPri true MatType Building ObjAssigned.i 794 ObjAssigned.u 7736345 TargetObj.i 390 TargetObj.u 7677674 END BEGIN "[i 394]" Id 12128 Type StoreObject CellX 130 CellY 74 HighPri true MatType DemolishWalls InProg true ObjAssigned.i 798 ObjAssigned.u 7736269 TargetObj.i 390 TargetObj.u 7677674 END BEGIN "[i 395]" Id 12129 Type ImproveCellIndoor CellX 115 CellY 52 WorkTotal 1.000000 END END END BEGIN Intake MaxIntake 5 DeathRowBlocked 0 BEGIN Categories BEGIN i PrisonerCategory MinSec Pool 7 Ratio 0.0000000 NextIntake 0 Queue 0 NumNITGs 0 END BEGIN i PrisonerCategory Normal Pool 100 Ratio 0.8000000 NextIntake 5 Queue 0 NumNITGs 0 END BEGIN i PrisonerCategory MaxSec Pool 2 Ratio 0.0000000 NextIntake 0 Queue 0 NumNITGs 0 END BEGIN i PrisonerCategory DeathRow Pool 0 Ratio 0.0000000 NextIntake 0 Queue 0 NumNITGs 0 END END END
Titouaix
Messages postés7Date d'inscriptionvendredi 13 décembre 2013StatutMembreDernière intervention20 décembre 2017 7 août 2015 à 18:15
Bonjour,
Tu veux extraire quoi du fichier et tu veux le mettre où dans une variable?
Il faudrait qu tu donne un exemple de ce que tu veux faire de ton extraction, qelles sont les valeurs qui t'interresse, etc ...