Jump to content

Recommended Posts

Posted

PLease read entire post before responding

I would like to remove ",1" located on the far right of my text file. Without removing ",1" that appears elsewhere in the text file. The text files shown below are executed in the autoit script.

I want the code to keep the bold ",1" but remove the bold+italicized ",1" 

Time,Mode,Band,Channel,Freq,LNA0_RX0,LockDetect
2013/07/19 20:17:13,GSM,PCS-1900, 512,1930.200, -111.27,1
2013/07/19 20:17:19,GSM,PCS-1900, 513,1930.400, -111.82,1
2013/07/19 20:17:25,GSM,PCS-1900, 514,1930.600, -111.88,1
2013/07/19 20:17:30,GSM,PCS-1900, 515,1930.800, -111.92,1
2013/07/19 20:17:36,GSM,PCS-1900, 516,1931.000, -111.93,1
2013/07/19 20:17:42,GSM,PCS-1900, 517,1931.200, -111.89,1
 
 
How do i modify my existing code that successfully removes   ",   23.00" from my text file? The autoit code for how I successfully removed 23.00 is attached. As you can tell its easier to remove "23.00' than ",1". 
 
 
Time,Mode,Band,Channel,Freq,LNA0_RX0,LNA0_RX1,TARGET_TX_PWR
2013/07/19 19:02:46,LTE,25-1930-10MHz,8040,1930.000,  -93.14,  -92.09,   23.00
2013/07/19 19:02:46,LTE,25-1930-10MHz,8041,1930.100,  -92.97,  -91.94,   23.00
2013/07/19 19:02:47,LTE,25-1930-10MHz,8042,1930.200,  -93.00,  -91.99,   23.00
2013/07/19 19:02:47,LTE,25-1930-10MHz,8043,1930.300,  -93.10,  -91.98,   23.00
2013/07/19 19:02:47,LTE,25-1930-10MHz,8044,1930.400,  -93.93,  -92.92,   23.00
2013/07/19 19:02:48,LTE,25-1930-10MHz,8045,1930.500,  -93.10,  -92.10,   23.00
2013/07/19 19:02:48,LTE,25-1930-10MHz,8046,1930.600,  -93.69,  -92.62,   23.00
2013/07/19 19:02:48,LTE,25-1930-10MHz,8047,1930.700,  -93.09,  -91.95,   23.00
2013/07/19 19:02:49,LTE,25-1930-10MHz,8048,1930.800,  -93.64,  -92.67,   23.00
 
 
 
 
 
 

post-80201-0-85706500-1374508965_thumb.p

Posted

#Include <Array.au3>

$str = "Time,Mode,Band,Channel,Freq,LNA0_RX0,LockDetect" & @CRLF & _
"2013/07/19 20:17:13,GSM,PCS-1900, 512,1930.200, -111.27,1" & @CRLF & _
"2013/07/19 20:17:19,GSM,PCS-1900, 513,1930.400, -111.82,1" & @CRLF & _
"2013/07/19 20:17:25,GSM,PCS-1900, 514,1930.600, -111.88,1" & @CRLF & _
"2013/07/19 20:17:30,GSM,PCS-1900, 515,1930.800, -111.92,1" & @CRLF & _
"2013/07/19 20:17:36,GSM,PCS-1900, 516,1931.000, -111.93,1" & @CRLF & _
"2013/07/19 20:17:42,GSM,PCS-1900, 517,1931.200, -111.89,1"

$aSTR = stringsplit($str , @CRLF , 1)

For $i = 1 to ubound($aSTR) - 1
    If stringright($aSTR[$i] , 2) = ",1" Then
        $aSTR[$i] = stringtrimright($aSTR[$i] , 2)
    EndIf
Next

$sStripped = _ArrayToString($aSTR , @CRLF , 1)

msgbox (0, '' , $sStripped)

  Reveal hidden contents

Posted

StringInStr ( "string", "substring" [, casesense [, occurrence [, start [, count]]]] )

 

Could be just me ... but the "occurrence" flag just might be what you're looking for, since it's the 2nd occurrence in each line ...

 

Failing that, you could read from the END of the string and work backwards by using a -1 for the occurrence.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Posted

try this

$s_test = ""
$s_test &= "2013/07/19 20:17:13,GSM,PCS-1900, 512,1930.200, -111.27,1" & @CRLF
$s_test &= "2013/07/19 20:17:19,GSM,PCS-1900, 513,1930.400, -111.82,1" & @CRLF
$s_test &= "2013/07/19 20:17:25,GSM,PCS-1900, 514,1930.600, -111.88,1" & @CRLF
$s_test &= "2013/07/19 20:17:30,GSM,PCS-1900, 515,1930.800, -111.92,1" & @CRLF
$s_test &= "2013/07/19 20:17:36,GSM,PCS-1900, 516,1931.000, -111.93,1" & @CRLF
$s_test &= "2013/07/19 20:17:42,GSM,PCS-1900, 517,1931.200, -111.89,1" & @CRLF

$s_out = StringRegExpReplace($s_test, '(?i)(.*?,.*?,.*?,.*?,.*?,.*?)(,.*?)\r\n', '$1' & @CRLF)
ConsoleWrite($s_out & @CRLF)

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...