Find and Replace
-
@tanquen said in Find and Replace:
Is there a way to tell it something like,
Find PCV(whatever is found here leave it as is)183502
Replace just the number and or maybe the first three letters.@Ekopalypse had almost given you the answer but as he wasn’t sure which numbers you wanted to select his solution included the
\d{6}
. So just replace that with your183501
.The
.
behind his PCV denotes any 1 character.Terry
-
Right now I’m using Excel to concatenate the two strings into the NatePad++ Find and Replace strings.
Then I have to create a second set to find the same tags with underscores.
Not great but it works and it’s better than doing 40+ unique search and replace operations manually.
-
Hello, @tanquen, @ekopalypse, @terry-r and All,
You said in a previous post :
So this:
PCV_183501
becomes this:
PCV_192102
and at the same time
PCV-183501
becomes this:
PCV-192102But, in the last picture of your last post, it seems that :
-
You want to find a string containing an underscore character
-
You want to change that string with a dash character
So, which statement is correct : the former or the later ?
IF the first solution is the right one, here is, below, the regex S/R to achieve this goal :
SEARCH
(S8_Filters)|(IBS8_Filter,)|(LIC(.)182301)|(LIT(.)182301)|(LSHH(.)182302)
REPLACE
(?1S9_Filters)(?2IBS9_Filter,)(?3LIC${4}192401)(?5LT${6}192401)(?7LSHH${8}192402)
So from this INPUT text :
S8_Filters IBS8_Filter, LIC-182301 LIT-182301 LSHH-182302 LIC_182301 LIT_182301 LSHH_182302
You would obtain the following OUTPUT text :
S9_Filters IBS9_Filter, LIC-192401 LT-192401 LSHH-192402 LIC_192401 LT_192401 LSHH_192402
Note that the
${4}
${6}
and${8}
substitution strings represent the symbol between the string and the number ( i.e. the_
or the-
character )Best Regards,
guy038
-
-
@guy038 said in Find and Replace:
But, in the last picture of your last post, it seems that :
Sorry about that, I did see that the second Excel expression was incorrect just after posting but it had been more than 3 minutes and I could not fix it. It was just an example of using Excel to build the Find and Replace strings.
The post before has the important bits.
“I want the - or _ to satay whatever it is in each string.”
and this as you quoted:
“So this:
PCV_183501
becomes this:
PCV_192102
and at the same time
PCV-183501
becomes this:
PCV-192102”The list of tags is much longer and I thought NotePad++ had a shorter limit but the last one I did was 447 characters. So far so good.
Your example output looks like what I want and it would be nice to only have to do one manual Find and Replace but doing just the two isn’t so bad.
I’m not following this bit: “(?3LIC${4}192401)(?5LT${6}192401)”
In my setup it’s just finding every instance of the third string (IBS8_Filter,) found and replacing it with (?3IBS9_Filter,). The “?3” in the Replace tells it to use this string "IBS9_Filter, as the replacement for the third set of found strings.
SEARCH ( )|(S8_Filters)|(IBS8_Filter,)|(LIC-182301)
REPLACE (?1 )(?2S9_Filters)(?3IBS9_Filter,)(?4LIC-192401)Now you are adding a wildcard “(.)” in the search for anything in between “IBS8” and “Filter,”? This third search could find many different stings. If it found more than two it still works as it saying whatever was found here “(.)”, goes here “${4}”?
SEARCH ( )|(S8_Filters)|(IBS8(.)Filter,)|(LIC-182301)
REPLACE (?1 )(?2S9_Filters)(?3IBS9${4}Filter,)(?5LIC-192401)I’m not that great at (anything really) Excel but I’d have to find a new way to increment the numbers by two for each tag in the replace string.
Thanks for the help/example!
-
@guy038 I’d now like to generate a list of unique tags. I saw your post on using the Mark function and someone’s thread about finding and select all words between select words. This text file is a CSV but I could not get it to mark even just text between to commas.
Most rows start something like this with no comma. I’m thinking that may be an issue.
FSH_184007,S8_Filters,Default,AG_182800,FSH-182807-ALM,AG_1833,FSH-184007-ALM,FSH-182807-ALM,AG_1833, LIT-1845 Tank Level,FSH_184007
Some tags start with 2 letters other with 3 and then some have a dash and others have underscores. Some then have a dash or underscore at the end. Some only have 4 number and others have 6.
I’d also like filter out the base loop number, 1840 and not include tags without the 4 to 6 digit loop number, 18XX. Also do not need to see the same tag if only the dash or underscore are different.
In the end I’d have a list of just these tags:
AG_182800
AG_1833
FSH-182807-ALM
LIT-1845 -
@tanquen said in Find and Replace:
This text file is a CSV but I could not get it to mark even just text between to commas.
Most rows start something like this with no comma. I’m thinking that may be an issue.As you call it a CSV file, then there will almost certainly be a fixed number of fields on every line. You imply that some rows do start with a comma, if so this is likely because the first field is empty.
What you aren’t doing very well is stating your need nor showing examples within the black box. This is necessary as the posting engine will sometimes interpret characters within the example as formatting commands, thereby changing the data.
So:
- show more example rows and this time within the black box, both rows starting with a comma and without
- explain which fields you need by showing the same examples as above in a separate black box with the result you are seeking
- confirm whether any of the fields contain double or single quotes as this will imply commas within the fields, not only separating the fields
So far you have made it very hard for seasoned forum members to effectively help you. It’s time for you to help us to help you, rather than us having to wring out this information from you.
Terry
PS as you did use a black box on your first post it implies you did read some of the FAQ posts, it’s time to read more. There is a wealth of information there on how to ask for help, such as plenty of examples within the black box. Before and after examples. Other information such as possible case situations where some data you don’t want may be collected in error.
-
@terry-r Just let me know what info you need. I think I did a good job listing everything with an example.
I could not get the code box to just show white text like others had done so I did not use it. It was coloring it like it was code. I thought that would be confusing and they looked unchanged.
The rows are so wide I did not want to spam the post. So I just showed a section of one row. It has an example of tags I’m looking for.
It is a CSV, don’t know what else to call it but it’s an output from an HMI application and I’ve been told it’s not 100% standard CSV and that is why Excel messes with it. I think Excel messes with any CSV, times dates, leading zeros and such.
Many rows have many fields and others do not. Looking at it again none start with a comma, none of the first ones are empty, a few header rows start with a “:”. There are blank rows and it only has empty cells/frields or just commas if there is a cell with text after. I’ve seen lot of aps that export to CSV do this. Are they not following the CSV standard, I don’t know, they so what they like. It’s also not adding a bunch of commas to make every row have the same number of fields.
Some fields do have double quotes.
If it’s ok to post really wide rows I can try that but it’s the same kind of stuff over and over.
FSH_184007,S8_Filters,Default,AG_182800,FSH-182807-ALM,AG_1833,FSH-184007-ALM,FSH-182807-ALM,AG_1833, LIT-1845 Tank Level,FSH_184007
Seen above, some tags start with 2 letters other with 3 and then some have a dash and others have underscores. Some then have a dash or underscore at the end. Some only have 4 numbers and others have 6.
I’d also like filter out the base loop number, 1840 and not include tags without the 4 to 6 digit loop number, 18XX. Also do not need to see the same tag if only the dash or underscore are different.
In the end I’d have a list of just these tags:
AG_182800 AG_1833 FSH-182807-ALM LIT-1845
-
@tanquen said in Find and Replace:
Just let me know what info you need.
I already asked you what is needed for anyone to help. We understand your reluctance but please do continue. Many
complete
example lines with before and after shots in separate black boxes. Disregard that some of the text is coloured inside the box, it’s just a side effect of the posting engine. The black box is the best way to maintain certainty over the data.Terry
-
Is this really needed?
"We understand your reluctance but please do continue. "
“So far you have made it very hard for seasoned forum members to effectively help you.”
“PS as you did use a black box on your first post it implies you did read some of the FAQ posts”If you don’t want to help me ok. Others were helpful and got the find and replace working. Even without the black box, that I’m more than willing to do and I already said why. I’m thankful for their help.
"Disregard that some of the text is coloured inside the box, it’s just a side effect of the posting engine. "
As I said, others had white text so I thought I was doing it wrong. How are they bypassing the “side effect of the posting engine”?
I don’t understand this. I did this? Many? I don’t know what else to show. That is all there is?
“Many complete example lines with before and after shots in separate black boxes.”Again “If it’s ok to post really wide rows I can try that but it’s the same kind of stuff over and over.”
“I already asked you what is needed for anyone to help.”
And I replied. ??? Put it in black boxes and done my best to describe what I needed.If you have any questions just let me know. I’m just looking for help.
-
@tanquen said in Find and Replace:
If you have any questions just let me know. I’m just looking for help.
As you stated earlier, the CSV file isn’t of a “regular” nature. Hence examples might allow me/others to help you.
So if you don’t wish to add further information then I guess I’m out. Good luck on getting anyone else to help. Sure, @guy038 has done well so far, but I’m picking the next step may well be impossible. Especially since you said:
Many rows have many fields and others do not. Looking at it again none start with a comma, none of the first ones are empty, a few header rows start with a “:”. There are blank rows and it only has empty cells/frields or just commas if there is a cell with text after. I’ve seen lot of aps that export to CSV do this. Are they not following the CSV standard, I don’t know, they so what they like. It’s also not adding a bunch of commas to make every row have the same number of fields.
I suspect that calling it a CSV file is actually wrong. The only commonality appears to be that your data uses commas as a delimiter.
In order for regular expressions to find data to extract there needs to be some uniformity about the data. You seem to be saying there is none.
Terry
PS I’m actually wondering if the "rows"you are talking about are some side effect of the output and in fact each field is a separate record. It’s just data. Without knowledge of how to interpret that data it’s useless
-
@terry-r said in Find and Replace:
So if you don’t wish to add further information then I guess I’m out.
Never said I would not add more info, just at a total loss as to what else to add. Just need to know what else is needed. It’s just a text file. So if every row does not begin with a comma you can’t search for the tags?
I don’t know who decides if its a real CSV. Unfortunately every HDMI/SCADA verder I’ve used for 30 years does it this way. One or two could export to an Excel file but all the rest and many other app just dump a file they call a CSV and has a commas as a delimiter and Excel can always open them it them changes the data and adds commas and so on. You also have to tell it every time that the CSV is a CSV and to you the commas as a delimiter.
Here is one section, the three rows repeat hundreds of times. In the text file it’s three rows that start like this.
The second and third rows are much longer.
This is just the first part of the three rows.:TEMPLATE=$Suite8_Dryer.EM_DRAgitator.SIC_MotorArmSpeed :Tagname,Area,SecurityGroup,Container,ContainedName,FriendlyName, SIC_184007A,S8_Filters,Default,AG_184000,SIC_MotorArmSpeed,
This is all. – Oh, I did not know it would formate it with the slider.
:TEMPLATE=$Suite8_Dryer.EM_DRAgitator.SIC_MotorArmSpeed :Tagname,Area,SecurityGroup,Container,ContainedName,FriendlyName,ShortDesc,ExecutionRelativeOrder,ExecutionRelatedObject,UDAs,Extensions,CmdData,CFG_EUMin_OIT.EngUnits,CFG_EUMax_OIT.Description,Manual.Description,CFG_EUMin.Description,InterlockEn.Description,DFSO_LogicEnable.Description,CFG_Severity_DFSO.Description,DFSO_AlmTmrSP.EngUnits,LocalRemote.Description,DirectionInput.Description,CFG_SpdInputMax.Description,Running.Description,CFG_Severity_SD.Description,CFG_SpdOutputMin.Description,CD_AlmTmrSP.EngUnits,CFG_EUMax.EngUnits,CFG_Use_RInput.Description,FInput.Description,Stopped.Description,CFG_Severity_CD.Description,FI_LogicEnable.Description,FI_AlmTmrSP.EngUnits,CmdMan.Description,SimEnable.Description,FaultResetCmd.Description,DirectionCmdAuto.Description,LocalRemote.OffMsg,DirectionOutput.OnMsg,DFSO_LogicEnable.OffMsg,DirectionInput.OnMsg,Manual.OffMsg,Manual.OnMsg,Run.OnMsg,DirectionCmdAuto.OffMsg,Stopped,SpdInputScaled,SimEnable,SD_UserAck,SD_LogicEnable,SD_AckQualityCheck,MaxSPLimit,Interlock_Descriptions,FInput,FI_LogicEnable,DirectionInput,DFSO_LogicEnable,DFSO_AckQualityCheck,CurrentScaled,CFG_UseDirectionInput,CFG_SpdOutputMax,CFG_Severity_SD,CFG_Severity_DFSO,CFG_Precision,CFG_EUMin,CFG_EUMax,CD_LogicEnable,CD_AckQualityCheck,SD_LogicEnable.OffMsg,SD_LogicEnable.OnMsg,Direction.OffMsg,Direction.OnMsg,FI_AlmTmrSP,FI_AckQualityCheck,FaultResetCmd,Manual,LocalRemote,InterlockNum,DFSO_LogicEnable.OnMsg,CD_LogicEnable.OffMsg,DirectionCmdMan,DirectionCmdAuto,Direction,Runtime_Hours.Description,MinSPLimit.Description,MaxSPLimit.Description,CFG_Severity_FI.Description,CD_LogicEnable.Description,DFSO_UserAck.Description,LocalRemote.OnMsg,FI_LogicEnable.OffMsg,Running.OffMsg,Running.OnMsg,CFG_Use_SpdInput,CFG_Use_RInput,CFG_Use_OIT_EU,DirectionCmdMan.OffMsg,DirectionCmdMan.OnMsg,Runtime_Hours,Running,Run,DirectionOutput.OffMsg,CFG_Use_SpdInput.Description,Run.Description,SpdInputScaled.Description,CFG_SpdInputMax.EngUnits,CD_UserAck,CFG_Severity_CD,CFG_SpdOutputMax.EngUnits,CFG_SpdInputMin,Run.OffMsg,DFSO_AlmTmrSP.Description,CFG_EUMax.Description,DirectionOutput.Description,SD_SP.Description,CD_AlmTmrSP,CFG_EUMin_OIT,SpdOutputCmd,SpdCmdMan.Description,CurrentScaled.Description,Interlock.Description,SD_SP.EngUnits,SpdOutputCmd.Description,CFG_EUMin_OIT.Description,CFG_EUMax_OIT.EngUnits,SD_UserAck.Description,CFG_EUMin.EngUnits,CFG_Severity_FI,CFG_SpdOutputMin,SD_AlmTmrSP.Description,CmdMan,DFSO_UserAck,CFG_EUMax_OIT,SD_LogicEnable.Description,CD_AlmTmrSP.Description,CD_LogicEnable.OnMsg,DirectionInput.OffMsg,MinSPLimit,FI_LogicEnable.OnMsg,CFG_SpdInputMin.EngUnits,DirectionCmdAuto.OnMsg,SD_AlmTmrSP,CFG_SpdOutputMax.Description,SpdCmdMan,DirectionCmdMan.Description,CFG_SpdOutputMin.EngUnits,CD_UserAck.Description,SD_SP,CFG_SpdInputMax,Direction.Description,CFG_SpdInputMin.Description,CFG_Precision.Description,InterlockEn,DirectionOutput,Interlock,FI_UserAck,DFSO_AlmTmrSP,CFG_UseDirectionInput.Description,FI_AlmTmrSP.Description,InterlockNum.Description,FI_UserAck.Description,_WizardDefinition_6,UserAttrData,CD_Ack_DC.AliasReferences,CD_Ack_Qual1.AliasReferences,CD_Ack_Qual2.AliasReferences,DFSO_Ack_DC.AliasReferences,DFSO_Ack_Qual1.AliasReferences,DFSO_Ack_Qual2.AliasReferences,FI_Ack_DC.AliasReferences,FI_Ack_Qual1.AliasReferences,FI_Ack_Qual2.AliasReferences,SD_Ack_DC.AliasReferences,SD_Ack_Qual1.AliasReferences,SD_Ack_Qual2.AliasReferences,CFG_EUMax.InputSource,CFG_EUMax.DiffOutputDest,CFG_EUMax.Deadband,CFG_EUMax.OutputDest,CFG_EUMin.InputSource,CFG_EUMin.DiffOutputDest,CFG_EUMin.Deadband,CFG_EUMin.OutputDest,CFG_SpdInputMax.InputSource,CFG_SpdInputMax.DiffOutputDest,CFG_SpdInputMax.Deadband,CFG_SpdInputMax.OutputDest,CFG_SpdInputMin.InputSource,CFG_SpdInputMin.DiffOutputDest,CFG_SpdInputMin.Deadband,CFG_SpdInputMin.OutputDest,CFG_SpdOutputMax.InputSource,CFG_SpdOutputMax.DiffOutputDest,CFG_SpdOutputMax.Deadband,CFG_SpdOutputMax.OutputDest,CFG_SpdOutputMin.InputSource,CFG_SpdOutputMin.DiffOutputDest,CFG_SpdOutputMin.Deadband,CFG_SpdOutputMin.OutputDest,CFG_Precision.InputSource,CFG_Precision.DiffOutputDest,CFG_Precision.Deadband,CFG_Precision.OutputDest,CFG_Use_RInput.InputSource,CFG_Use_RInput.DiffOutputDest,CFG_Use_RInput.InvertValue,CFG_Use_RInput.OutputDest,CFG_Use_SpdInput.InputSource,CFG_Use_SpdInput.DiffOutputDest,CFG_Use_SpdInput.InvertValue,CFG_Use_SpdInput.OutputDest,CmdMan.InputSource,CmdMan.DiffOutputDest,CmdMan.Deadband,CmdMan.OutputDest,FInput.InputSource,FInput.DiffOutputDest,FInput.InvertValue,FInput.OutputDest,Manual.InputSource,Manual.DiffOutputDest,Manual.InvertValue,Manual.OutputDest,Run.InputSource,Run.DiffOutputDest,Run.InvertValue,Run.OutputDest,Running.InputSource,Running.DiffOutputDest,Running.InvertValue,Running.OutputDest,SimEnable.InputSource,SimEnable.DiffOutputDest,SimEnable.InvertValue,SimEnable.OutputDest,SpdCmdMan.InputSource,SpdCmdMan.DiffOutputDest,SpdCmdMan.Deadband,SpdCmdMan.OutputDest,SpdInputScaled.InputSource,SpdInputScaled.DiffOutputDest,SpdInputScaled.Deadband,SpdInputScaled.OutputDest,SpdInputScaled.ForceStoragePeriod,SpdInputScaled.TrendHi,SpdInputScaled.TrendLo,SpdInputScaled.EngUnits,SpdInputScaled.Hist.DescAttrName,SpdInputScaled.InterpolationType,SpdInputScaled.RolloverValue,SpdInputScaled.SampleCount,SpdInputScaled.EnableSwingingDoor,SpdInputScaled.RateDeadBand,SpdOutputCmd.InputSource,SpdOutputCmd.DiffOutputDest,SpdOutputCmd.Deadband,SpdOutputCmd.OutputDest,Stopped.InputSource,Stopped.DiffOutputDest,Stopped.InvertValue,Stopped.OutputDest,Interlock.InputSource,Interlock.DiffOutputDest,Interlock.Deadband,Interlock.OutputDest,FaultResetCmd.InputSource,FaultResetCmd.DiffOutputDest,FaultResetCmd.InvertValue,FaultResetCmd.OutputDest,CurrentScaled.InputSource,CurrentScaled.DiffOutputDest,CurrentScaled.Deadband,CurrentScaled.OutputDest,CFG_Severity_CD.InputSource,CFG_Severity_CD.DiffOutputDest,CFG_Severity_CD.Deadband,CFG_Severity_CD.OutputDest,CFG_Severity_DFSO.InputSource,CFG_Severity_DFSO.DiffOutputDest,CFG_Severity_DFSO.Deadband,CFG_Severity_DFSO.OutputDest,CFG_Severity_FI.InputSource,CFG_Severity_FI.DiffOutputDest,CFG_Severity_FI.Deadband,CFG_Severity_FI.OutputDest,Running.LogDataChangeEvent,CD_UserAck.InputSource,CD_UserAck.DiffOutputDest,CD_UserAck.InvertValue,CD_UserAck.OutputDest,DFSO_UserAck.InputSource,DFSO_UserAck.DiffOutputDest,DFSO_UserAck.InvertValue,DFSO_UserAck.OutputDest,FI_UserAck.InputSource,FI_UserAck.DiffOutputDest,FI_UserAck.InvertValue,FI_UserAck.OutputDest,FI_LogicEnable.InputSource,FI_LogicEnable.DiffOutputDest,FI_LogicEnable.InvertValue,FI_LogicEnable.OutputDest,DFSO_LogicEnable.InputSource,DFSO_LogicEnable.DiffOutputDest,DFSO_LogicEnable.InvertValue,DFSO_LogicEnable.OutputDest,CD_LogicEnable.InputSource,CD_LogicEnable.DiffOutputDest,CD_LogicEnable.InvertValue,CD_LogicEnable.OutputDest,DFSO_AlmTmrSP.InputSource,DFSO_AlmTmrSP.DiffOutputDest,DFSO_AlmTmrSP.Deadband,DFSO_AlmTmrSP.OutputDest,CD_AlmTmrSP.InputSource,CD_AlmTmrSP.DiffOutputDest,CD_AlmTmrSP.Deadband,CD_AlmTmrSP.OutputDest,FI_AlmTmrSP.InputSource,FI_AlmTmrSP.DiffOutputDest,FI_AlmTmrSP.Deadband,FI_AlmTmrSP.OutputDest,CFG_Severity_SD.InputSource,CFG_Severity_SD.DiffOutputDest,CFG_Severity_SD.Deadband,CFG_Severity_SD.OutputDest,SD_AlmTmrSP.InputSource,SD_AlmTmrSP.DiffOutputDest,SD_AlmTmrSP.Deadband,SD_AlmTmrSP.OutputDest,SD_UserAck.InputSource,SD_UserAck.DiffOutputDest,SD_UserAck.InvertValue,SD_UserAck.OutputDest,SD_LogicEnable.InputSource,SD_LogicEnable.DiffOutputDest,SD_LogicEnable.InvertValue,SD_LogicEnable.OutputDest,CFG_UseDirectionInput.InputSource,CFG_UseDirectionInput.DiffOutputDest,CFG_UseDirectionInput.InvertValue,CFG_UseDirectionInput.OutputDest,Direction.InputSource,Direction.DiffOutputDest,Direction.InvertValue,Direction.OutputDest,DirectionOutput.InputSource,DirectionOutput.DiffOutputDest,DirectionOutput.InvertValue,DirectionOutput.OutputDest,DirectionCmdAuto.InputSource,DirectionCmdAuto.DiffOutputDest,DirectionCmdAuto.InvertValue,DirectionCmdAuto.OutputDest,LocalRemote.InputSource,LocalRemote.DiffOutputDest,LocalRemote.InvertValue,LocalRemote.OutputDest,CurrentScaled.ValueDeadBand,CurrentScaled.ForceStoragePeriod,CurrentScaled.TrendHi,CurrentScaled.TrendLo,CurrentScaled.EngUnits,CurrentScaled.Hist.DescAttrName,CurrentScaled.InterpolationType,CurrentScaled.RolloverValue,CurrentScaled.SampleCount,CurrentScaled.EnableSwingingDoor,CurrentScaled.RateDeadBand,SpdOutputCmd.ForceStoragePeriod,SpdOutputCmd.TrendHi,SpdOutputCmd.TrendLo,SpdOutputCmd.EngUnits,SpdOutputCmd.Hist.DescAttrName,SpdOutputCmd.InterpolationType,SpdOutputCmd.RolloverValue,SpdOutputCmd.SampleCount,SpdOutputCmd.EnableSwingingDoor,SpdOutputCmd.RateDeadBand,DirectionInput.InputSource,DirectionInput.DiffOutputDest,DirectionInput.InvertValue,DirectionInput.OutputDest,DirectionCmdMan.InputSource,DirectionCmdMan.DiffOutputDest,DirectionCmdMan.InvertValue,DirectionCmdMan.OutputDest,SD_SP.InputSource,SD_SP.DiffOutputDest,SD_SP.Deadband,SD_SP.OutputDest,InterlockEn.InputSource,InterlockEn.DiffOutputDest,InterlockEn.Deadband,InterlockEn.OutputDest,Direction.LogDataChangeEvent,Runtime_Hours.InputSource,Runtime_Hours.DiffOutputDest,Runtime_Hours.Deadband,Runtime_Hours.OutputDest,Runtime_Hours.ValueDeadBand,Runtime_Hours.ForceStoragePeriod,Runtime_Hours.TrendHi,Runtime_Hours.TrendLo,Runtime_Hours.EngUnits,Runtime_Hours.Hist.DescAttrName,Runtime_Hours.InterpolationType,Runtime_Hours.RolloverValue,Runtime_Hours.SampleCount,Runtime_Hours.EnableSwingingDoor,Runtime_Hours.RateDeadBand,CFG_EUMax_OIT.InputSource,CFG_EUMax_OIT.DiffOutputDest,CFG_EUMax_OIT.Deadband,CFG_EUMax_OIT.OutputDest,CFG_EUMin_OIT.InputSource,CFG_EUMin_OIT.DiffOutputDest,CFG_EUMin_OIT.Deadband,CFG_EUMin_OIT.OutputDest,CFG_Use_OIT_EU.InputSource,CFG_Use_OIT_EU.InvertValue SIC_184007A,S8_Filters,Default,AG_184000,SIC_MotorArmSpeed,SIC_184007A,AG-1840 Motor Arm Speed Control,None,,<UDAInfo></UDAInfo>,<ExtensionInfo><ObjectExtension/><AttributeExtension/></ExtensionInfo>,<CmdData><BooleanLabel></BooleanLabel></CmdData>,RPM,Configuration of Engineering Unit Maximum on HMI,"Manual Mode (0=Auto, 1=Manual)",Configuration of Engineering Unit Minimum,Interlock Enable Input,Speed Output Data Fault Alarm Logic Enable,"Configuration of Severity for Speed Output Data Fault ",ms,"Local Control (0 – local, 1 – remote)","Direction Status (0 - Clockwise, 1 – Counterclockwise) ",Configuration of Speed Input Maximum,"Running Status ",Configuration of Severity for Command Disagree,Configuration of Speed Output Maximum,ms,%,"Configuration to Use Running Input ",Drive Fault Input from Field Device,Stopped Status,Configuration of Severity for Command Disagree,Drive Fault Input Alarm Logic Enable,ms,"Manual Mode Command (0=Stop, 1=Run)",Enable Simulation Mode,Command to Reset Drive Fault,"Direction Command from Logic (0 - Clockwise, 1 – Counterclockwise) ",Local,CCW,Disabled,CCW,Auto,Manual,Run,CW,false,0.0,false,false,false,0,200.0,"Evacuation Alarm,,,,,,,,,,,,,,,",false,false,false,false,0,0.0,false,100.0,0,0,0,0.0,100.0,false,0,Disabled,Enabled,CW,CCW,0,0,false,false,false,1,Enabled,Disabled,false,false,false,Enter attribute description,Operator SP min limit,Operator SP max limit,"Configuration of Severity for Drive Fault Input ",Command Disagree Logic Enable,Speed Output Data Fault Alarm User Acknowledge,Remote,Disabled,Running,Stopped,false,false,false,CW,CCW,0,false,false,CW,Configuration to Use Speed Input,"Run Command ",Scaled Speed Input Value in Engineering Units,%,false,0,%,0.0,Stop,Speed Output Data Fault Alarm Timer Setpoint,Configuration of Engineering Unit Maximum,"Direction Output to the Device (0 - Clockwise, 1 – Counterclockwise) ",Speed Disagree Alarm Setpoint,0,0.0,0.0,Manual Mode Speed Output Command,Drive Output Current Scaled to Amps,Interlock Input,%,Speed Output Command in Engineering Units,Configuration of Engineering Unit Minimum on HMI,RPM,Speed Disagree Alarm User Acknowledge,%,0,0.0,Speed Disagree Alarm Timer Setpoint,0,false,0.0,Speed Disagree Logic Enable,Command Disagree Alarm Timer Setpoint,Enabled,CW,0.0,Enabled,%,CCW,0,Configuration of Speed Output Maximum,0.0,"Direction Command from HMI (0 - Clockwise, 1 – Counterclockwise) ",%,Command Disagree Alarm User Acknowledge,0.0,100.0,"Direction Status (0 - Clockwise, 1 – Counterclockwise) ",Configuration of Speed Input Minimum,Precision for Operator Interface (Decimal Places),0,false,0,false,0,"Configuration to Use Direction Input from the Device ",Drive Fault Input Alarm Timer Setpoint,Number of Interlock Inputs,Drive Fault Input Alarm User Acknowldge,"<WizardState Version=""2"" xmlns=""clr-namespace:ArchestrA.EditorFramework.ViewModel.Wizard.Serialization;assembly=AttributesTab"" xmlns:aaefvmwc=""clr-namespace:ArchestrA.EditorFramework.ViewModel.Wizard.Collections;assembly=AttributesTab""><WizardState.Configuration><aaefvmwc:ChoiceGroupCollection /></WizardState.Configuration><WizardState.InstanceOverrides><aaefvmwc:AssociationCollection /></WizardState.InstanceOverrides><WizardState.DefaultMasterValues><aaefvmwc:AssociationCollection /></WizardState.DefaultMasterValues></WizardState>",<AttrXML/>,No Data,No Data,No Data,No Data,No Data,No Data,No Data,No Data,No Data,No Data,No Data,No Data,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,0.0,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,0,10.0,0.0,%,me.SpdInputScaled.Description,SystemDefault,0.0,0,false,0.0,---Auto---,false,0.0,---,---Auto---,false,false,---,---Auto---,false,0.0,---,---Auto---,false,false,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,true,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,false,---,0.0,0,10.0,0.0,A,me.CurrentScaled.Description,SystemDefault,0.0,0,false,0.0,0,10.0,0.0,%,me.SpdOutputCmd.Description,SystemDefault,0.0,0,false,0.0,---Auto---,false,false,---,---Auto---,false,false,---,---Auto---,false,0.0,---,---Auto---,false,0.0,---,true,---Auto---,false,0.0,---,0.0,0,10.0,0.0,Hrs,me.Runtime_Hours.Description,SystemDefault,0.0,0,false,0.0,---Auto---,false,0.0,---,---Auto---,false,0.0,---,---Auto---,false,
-
@tanquen said in Find and Replace:
Here is one section, the three rows repeat hundreds of times. In the text file it’s three rows that start like this.
The second and third rows are much longer.
This is just the first part of the three rows.You finally did what was needed. I’m not sure if you understand what the data is telling you so I’ll explain how I see it.
- a record is these 3 lines, they must stay together as a “set”.
- The first line probably denotes a particular piece of equipment (HMI as you call it).
- The second line identifies what fields are being exported on the 3rd line.
- The third line has the actual data contained within each field referenced on the second line.
Yes there are some fields which contain quotes so that made it harder to tie up the pairs. I would expect each unit (HMI) unless of the same model and S/W version might well output different record types. So don’t expect to see say the 2nd/3rd line sets of different units having the same number of fields.
Now you need to explain which fields you need to extract. I’m thinking this is going to be difficult with regex. As there will likely be no guarantee every record set has say the 4th, 5th, 8th, 12th etc field of the type you want, it will likely rely on the field header value to fix the position of the data.
My initial thoughts are either using pythonscript to gather up the field “pairs” or if done through regex it would take several steps to massage the data into a format that can be used to extract your data.
Terry
-
@terry-r said in Find and Replace:
You finally did what was needed.
:( I’m just asking for help not to insult or be insulted. I just try to help and answer as best I can. I asked if that should be posted, but it would be really long and just the same stuff over and over. You could have just said something like: “Sorry, yes go ahead and post that, it could have important info.” What if the origin string I posted was all there was, would that change how the regex find works?
I’m old and slow and it takes a long time to make a post and I still get spelling wrong and so on. I did not think adding a full “set” or the whole file was needed and would not fix “Many complete example lines with before and after shots in separate black boxes.”
“1. a record is these 3 lines, they must stay together as a “set”.”
How does it effects the find? I want to make a list of the unique tags. I’m guessing the find is more complicated if there are no easy start and stop characters? What if it’s just a bunch of text with no real format?
“2. The first line probably denotes a particular piece of equipment (HMI as you call it).”
Its the name of the template being referenced to create the new object in the application.
“3. The second line identifies what fields are being exported on the 3rd line.”
Yes, I did not think the first two lines were helpful as there are hundreds of objects and they have different number of fields.
“4. The third line has the actual data contained within each field referenced on the second line.”
That is why I posted it. It’s the stuff I’m looking for and has some dubble quotes and the commas just not at the start of the line.“Yes there are some fields which contain quotes so that made it harder to tie up the pairs.”
Why are the pairs needed?“So don’t expect to see say the 2nd/3rd line sets of different units having the same number of fields.”
Yes, I had said some have many more fields than others. How will that affect the find?“Now you need to explain which fields you need to extract. I’m thinking this is going to be difficult with regex. As there will likely be no guarantee every record set has say the 4th, 5th, 8th, 12th etc field of the type you want, it will likely rely on the field header value to fix the position of the data.”
I’m not looking at the types, I’m just looking for the tags. Is regex aware of the file type? I just want to find the tags in the data I posted. Does it matter if there are other rows with different headers or numbers of headers?I guess if there is other unknown text in the file it could break the Regex find?
I thought maybe you could use the commas and find what was in-between?
I’d just like to generate a list of unique tags from that first string i posted and the other string like it in the larger file.
That is why I tried to describe what is unique about the tags.
“Some tags start with 2 letters other with 3 and then some have a dash and others have underscores. Some then have a dash or underscore at the end. Some only have 4 number and others have 6.”
Something I’m thinking of now is that all the tags I want in this particular file have “18” in them but what if other files do not?In Excel, it correctly puts all the data into their own cells.
It then gives me a list of all the cells with the tags in it. This what I need but I don’t know of a way to copy the list and it’s finding the same tags over and over. I thought maybe Regex could do something cooler.
-
@tanquen said in Find and Replace:
“Some tags start with 2 letters other with 3 and then some have a dash and others have underscores. Some then have a dash or underscore at the end. Some only have 4 number and others have 6.”
Something I’m thinking of now is that all the tags I want in this particular file have “18” in them but what if other files do not?So can Regex do something like, search all text in file, give me strings of characters, find the beginning looking for any 2 or 3 letter only characters that are followed by a dash “-” or underscore “_” then continue until a comma or space is found? Not sure if that covers everything but something of this nature.
-
@tanquen said in Find and Replace:
looking for any 2 or 3 letter only characters that are followed by a dash “-” or underscore “_” then continue until a comma or space is found?
For that portion of the regex (not including anything else from your requirements):
(?i)[A-Z]{2,3}[_-][^,]*,
(?i)
makes it case insensitive[A-Z]
matches ASCII alphabet{2,3}
means it will match either 2 or 3 of the previous (the letters)[_-]
matches either_
or-
[^,]*
matches 0 or more characters that are not comma- you might want to change to
[^,\r\n]*
for this token to avoid grabbing newlines as well
- you might want to change to
,
matches comma
If you want “from the beginning of the line, through all that” with the “no newlines” variant:
^.*?(?i)[A-Z]{2,3}[_-][^,\r\n]*,
----
Useful References
-
Thanks very much, that was very helpful.
I used this to get just the tags as it was finding some other underscores and dashes that were in text other than tags.
(?i)[A-Z]{1,4}[_-][0-9][^,]*,
The only other thing I wanted was to not have duplicates but I can use the copy marked text and paste it into Excel and short it.
-
@tanquen said in Find and Replace:
The only other thing I wanted was to not have duplicates but I can use the copy marked text and paste it into Excel and short it.
I’m glad you are able to get what you need without a lot of text editing. As long as you are sure that ONLY the tags you want are of this format you should be OK.
Once you copy marked text, put it into another “new” tab in Notepad++. Then you can use the sort lines option to put duplicated lines beside each other. Then use the “Remove duplicated lines” option under Edit, Line Operations to remove all but 1 of each type. Then copy into Excel.
@PeterJones mentioned about the
[^,]*
portion of your regex and made the suggestion to alter that. I would take heed on that as if any of the tags you want are the last field on a line, there isn’t a final,
before the line ending. Your regex would continue capturing characters on the next line.Terry
-
@peterjones said in Find and Replace:
you might want to change to [^,\r\n]* for this token to avoid grabbing newlines as well
Not sure what the issue is. For this file type the template and header rows do not end with a comma. The first field doesn’t start with a comma but that seems to be ok as it sees it correctly as a tag and stops at the first comma. So far, these rows also always end with a comma.
If two lines where like this and did not end in a comma and ended with a tag:
DFO_129,S9_Filters,Default,XV_195401,DFO_129 CD_132,S9_Filters,Default,XV_195401,CD_132
I could maybe endup with this?
DFO_129CD_132
I think I’m ok, it seems to work and all the rows with tags end with a comma and if they did not the result would jump out at me, maybe.
Is there any easy way to stop at the comma but not include it? Seen some examples using Find and Replace to remove an end character but not just in the find expression for marking.