Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the columns are separated by tabs then you could use <a href="http://www.autoitscript.com/autoit3/docs/functions/StringSplit.htm" rel="nofollow noreferrer">StringSplit</a> for that.</p> <pre><code>$s1 = '1 502 shop 25.00' $s2 = '2 106 house 50.00' $s3 = '3 307 boat 15.00' For $i=1 To 3 $array = StringSplit(Eval('s' &amp; $i), @TAB) ConsoleWrite('Column 2: "' &amp; StringStripWS($array[2], 8) &amp; '"' &amp; @CRLF) ConsoleWrite('Column 4: "' &amp; StringStripWS($array[4], 8) &amp; '"' &amp; @CRLF) Next </code></pre> <p>This sample code will print:</p> <pre><code>Column 2: "502" Column 4: "25.00" Column 2: "106" Column 4: "50.00" Column 2: "307" Column 4: "15.00" </code></pre> <p><strong>EDIT</strong></p> <p>This example creates a CSV file, then reads the file back in and searches every line for '106'. If the string is found and the last column has the value of '50.00', then this value is replaced with '22.00'. The result is written to a new CSV file.</p> <pre><code>; write the data to the CSV file Global $hFile = FileOpen('test.csv', 10) If $hFile = -1 Then Exit FileWrite($hFile, '1' &amp; @TAB &amp; '502 ' &amp; @TAB &amp; 'shop' &amp; @TAB &amp; '25.00' &amp; @CRLF &amp; _ '2' &amp; @TAB &amp; '106 ' &amp; @TAB &amp; 'house' &amp; @TAB &amp; '50.00' &amp; @CRLF &amp; _ '3' &amp; @TAB &amp; '307' &amp; @TAB &amp; 'boat' &amp; @TAB &amp; '15.00') FileClose($hFile) ; read the CSV file and create a new one If Not FileExists('test.csv') Then Exit Global $hFileIn = FileOpen('test.csv') Global $hFileOut = FileOpen('test_new.csv', 10) While 1 Global $sLine = FileReadLine($hFileIn) If @error = -1 Then ExitLoop If StringInStr($sLine, '106') Then $sLine = _ReplacePrices($sLine) ConsoleWrite('New price: ' &amp; $sLine &amp; @CRLF) EndIf FileWriteLine($hFileOut, $sLine) WEnd FileClose($hFileIn) FileClose($hFileOut) Exit ; search for "106" find that and the corresponding value in ; column 4 (50.00) and change the column 4 value to "22.00" Func _ReplacePrices($sLineFromCSVFile) Local $array = StringSplit($sLineFromCSVFile, @TAB) If StringStripWS($array[2], 8) = '106' And _ StringStripWS($array[4], 8) = '50.00' Then Return $array[1] &amp; @TAB &amp; $array[2] &amp; @TAB &amp; _ $array[3] &amp; @TAB &amp; '22.00' EndIf EndFunc </code></pre> <p>If you run the example this will be the result:</p> <p><img src="https://i.stack.imgur.com/GogFY.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload