Jump to content

wvzuilen

Members
  • Posts

    7
  • Joined

  • Last visited

Profile Information

  • Location
    The Netherlands

wvzuilen's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thanks for your suggestions. I'll try the XML DOM first.
  2. Hi all, I've got a huge xml file I want to edit automatically. Over 10 million rows. First I used a for-next loop with FileReadLine, that took ages... of course... Then I tried reading the file to a array, editing the array by replacing certain values and then wrote the array back to a xml file. That worked. Much faster then editing the xml file itself. #include <File.au3> #include <Array.au3> $filename = "OUTPUT_OPDRACHTEN_20120411_221538.xml" Local $aArray ConsoleWrite("Reading file..." & @LF) _FileReadToArray($filename, $aArray) ConsoleWrite("Reading file... Ready!" & @LF) $lines = UBound($aArray) $count = 0 ConsoleWrite("Changing..." & @LF) For $i = 0 To $lines - 1 If StringInStr($aArray[$i], "<BC_INCASSO>") > 0 Then $aArray[$i] = "<BC_INCASSO xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:nil=""true""/>" $count = $count + 1 ;ConsoleWrite($i & @LF) EndIf If StringInStr($aArray[$i], "<OS_OMA_ONDW_OMA>Wijziging</OS_OMA_ONDW_OMA>") > 0 Then $aArray[$i] = "<OS_OMA_ONDW_OMA>Verlenging</OS_OMA_ONDW_OMA>" EndIf Next ConsoleWrite("Changing... Ready!" & @LF) ConsoleWrite("Writing file" & @LF) $new = FileOpen("new.xml", 129) For $i = 1 To $lines - 1 FileWriteLine($new, $aArray[$i]) Next FileClose($new) ConsoleWrite("Writing file... Ready!" & @LF) ConsoleWrite($count & @LF) But now, the next step.... I would like to insert a few rows of code in certain places of the array, but that takes ages again. I guess that's because when I add a new value (_ArrayInsert) on let's say index 5 and it's a array with 10.000.000 values, it has to re-index all values below that new value. If StringInStr($aArray[$i], "") > 0 Then $aArray[$i] = "ID1" _ArrayInsert($aArray,$i+2,"") _ArrayInsert($aArray,$i+3,"ID2") _ArrayInsert($aArray,$i+4,"") ConsoleWrite($i & @LF) EndIf Does anybody has a idea how I can do this reasonably fast ? Greetings.
  3. I noticed that, I edited one of my CSV files and removed a trailing, useless linefeed. But the array created by ProgAndy's _ParseCSV then missed a row. So I added the linefeed again
  4. Thanks ! With this example I got it working ! #include <CSV.au3> #include <File.au3> #include <Array.au3> Local $Cilinder_cat Local $Clausule_reg Local $Commercieel1 Local $CP_kanaal Local $CP_leeft Local $CP_Loy_Pntn Local $CP_noclaim Local $Dekking_OO Local $Dichtheid Local $Eigen_Risico_code Local $Eigen_risico Local $Heading Local $Inhoudsopgave Local $KM Local $Land_code Local $Leeftijd_Cat Local $Merk Local $Merk_clause Local $No_Claim Local $OAR Local $PC_Dichtheid Local $PC_Regio Local $PF_Eigen_Risico Local $Provincie Local $Provisie Local $Provisie_MAX Local $Regio Local $RF_Bouwjaar Local $RF_Buitenl Local $RF_Catalogus Local $RF_Cilinder Local $RF_Dichtheid Local $RF_Eig_Risk Local $RF_KM Local $RF_Leeftijd Local $RF_Merk Local $RF_Provincie Local $RF_Regio Local $RF_Type_motor Local $Risk Local $Type Local $Variabelen Local $VB_Risk Local $Voertuigsrt Local $aCSV = _FileListToArray(@ScriptDir & "CSV", "*", 1) For $i = 1 To $aCSV[0] $filename = $aCSV[$i] Local $aTemp = _ParseCSV(@ScriptDir & "CSV" & $filename) ;parse array to temp variable $filename = StringTrimRight($filename, 4) ; remove extension Assign($filename, $aTemp) ; Copy the array to the target array Next _ArrayDisplay($Cilinder_cat) ; Display first target array
  5. I tried this, but I cant get it to work: #include <CSV.au3> #include <File.au3> #include <Array.au3> Local $aCSV = _FileListToArray(@ScriptDir & "CSV", "*", 1) For $i = 1 To $aCSV[0] $filename = $aCSV[$i] $aTemp = _ParseCSV(@ScriptDir & "CSV" & $filename) ;parse array to temp variable $filename = StringTrimRight($filename,4) ; remove extension Assign( $filename , $aTemp) Next _ArrayDisplay($aCSV)
  6. Nope, I need all the data to calculate a insurance premium.
  7. Hi all, I got a question, but first I would like to thank all the posters of this forum. I've been coding AutoIT for a while now and I've used this forum a lot ! Thanks ! But now's I've got a question of wich I haven't find the answer so far. I've got a folder with 50 CSV files and I would like to read those files to arrays. I would like to give the array the same name as the filename. So filename1.csv to $filename1, filename2.csv to $filename2 etc. My code so far: #include <CSV.au3> #include <File.au3> #include <Array.au3> Local $aCSV = _FileListToArray(@ScriptDir & "\CSV", "*", 1) For $i = 1 To $aCSV[0] $????? = _ParseCSV(@ScriptDir & "\CSV\" & $aCSV[$i]) Next But how the declare / name the array within the loop? "$" & StringTrimRight($aCSV[$i],4) doesn't work (of course).
×
×
  • Create New...