If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Text filtering/replacement
5 posts
• Page 1 of 1
Text filtering/replacement
Hello.
I am looking for efficient way to edit data files which contain data line I do not need. Here is an example:
0.000 -0.005 -0.005 -0.005 1.245 9.588 -2.027
0.001 -0.005 -0.005 -0.005 1.245 9.588 -2.027
0.002 -0.005 -0.005 -0.005 1.245 9.588 -2.027
0.003 0.000 -0.005 -0.005 1.245 4.632 -1.626
START
0.004 0.000 -0.005 -0.005 1.245 4.632 -1.626
0.005 0.000 0.000 -0.005 1.245 0.079 -1.258
0.006 0.000 0.000 -0.005 1.250 0.079 -1.258
0.007 -0.005 -0.005 -0.005 1.245 9.588 -2.027
0.008 0.000 0.000 -0.005 1.250 0.079 -1.258
STOP
0.009 0.000 0.000 -0.005 1.245 0.079 -1.258
0.010 0.000 -0.005 -0.005 1.245 4.632 -1.626
START
0.011 0.000 0.000 -0.005 1.245 0.079 -1.258
0.012 0.000 -0.005 -0.005 1.245 4.632 -1.626
0.013 0.000 0.000 -0.005 1.240 0.079 -1.258
0.014 0.000 0.000 -0.005 1.245 0.079 -1.258
0.015 0.000 0.000 -0.005 1.240 0.079 -1.258
0.016 -0.005 -0.005 -0.005 1.245 9.588 -2.027
0.017 0.000 0.000 -0.005 1.245 0.079 -1.258
0.018 0.000 0.000 -0.005 1.245 0.079 -1.258
0.019 0.000 0.000 -0.005 1.250 0.079 -1.258
0.020 0.000 0.000 -0.005 1.245 0.079 -1.258
STOP
I need somehow to delete lines containing STOP and START words and keep columns so there is no gap in data. Was trying to split data and join it. But that way need some kind of loop and store string temporary...
How else to remove just those strings which containing START STOP?
Thank you
I am looking for efficient way to edit data files which contain data line I do not need. Here is an example:
0.000 -0.005 -0.005 -0.005 1.245 9.588 -2.027
0.001 -0.005 -0.005 -0.005 1.245 9.588 -2.027
0.002 -0.005 -0.005 -0.005 1.245 9.588 -2.027
0.003 0.000 -0.005 -0.005 1.245 4.632 -1.626
START
0.004 0.000 -0.005 -0.005 1.245 4.632 -1.626
0.005 0.000 0.000 -0.005 1.245 0.079 -1.258
0.006 0.000 0.000 -0.005 1.250 0.079 -1.258
0.007 -0.005 -0.005 -0.005 1.245 9.588 -2.027
0.008 0.000 0.000 -0.005 1.250 0.079 -1.258
STOP
0.009 0.000 0.000 -0.005 1.245 0.079 -1.258
0.010 0.000 -0.005 -0.005 1.245 4.632 -1.626
START
0.011 0.000 0.000 -0.005 1.245 0.079 -1.258
0.012 0.000 -0.005 -0.005 1.245 4.632 -1.626
0.013 0.000 0.000 -0.005 1.240 0.079 -1.258
0.014 0.000 0.000 -0.005 1.245 0.079 -1.258
0.015 0.000 0.000 -0.005 1.240 0.079 -1.258
0.016 -0.005 -0.005 -0.005 1.245 9.588 -2.027
0.017 0.000 0.000 -0.005 1.245 0.079 -1.258
0.018 0.000 0.000 -0.005 1.245 0.079 -1.258
0.019 0.000 0.000 -0.005 1.250 0.079 -1.258
0.020 0.000 0.000 -0.005 1.245 0.079 -1.258
STOP
I need somehow to delete lines containing STOP and START words and keep columns so there is no gap in data. Was trying to split data and join it. But that way need some kind of loop and store string temporary...
How else to remove just those strings which containing START STOP?
Thank you
- GLIC
- Posts: 11
- Joined: Tue Sep 11, 2018 3:00 pm
Re: Text filtering/replacement
I would usually go with Ruby for that kind of thing - it's a bit of a learning curve if you're not used to it, of course, but it's very good for any kind of String handling. For the example you've given, I'd probably use something like this (which should copy/paste into a RubyEdit primitive with the default String input and output)...
The "unless line.start_with?(...)" part can use "if" instead of "unless", and all manner of different tests for the line are possible in Ruby, even "regular expressions" (Regexp) which can match the general format of a String rather than very specific sub-strings as here.
- Code: Select all
output(
@in.each_line.with_object("") do |line, new_string|
new_string << line unless line.start_with?("START", "STOP")
end
)
The "unless line.start_with?(...)" part can use "if" instead of "unless", and all manner of different tests for the line are possible in Ruby, even "regular expressions" (Regexp) which can match the general format of a String rather than very specific sub-strings as here.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Text filtering/replacement
Moderator Note: Other posts have been split off into a new thread to keep the OPs topic clear: Ruby (learning and language comparisons)
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Text filtering/replacement
It did worked. Thank you.
I finding Ruby very difficult to learn (most other languages as well).
For typical programmer probably its hard to see, but programmers have different type of thinking from the rest of the people and programming by typing text works well for them. For people like me who is more technical/electronic based specialist visual programming is easier solution that typical programming. Its like, you do not ask builders to make bricks - you asking them to build building. Same with programming - programmers can be very good on building nodes/building blocks, but not necessary good with ideas,GUI or something else.
I wish there was a visual programming language where you have all necessary building blocks to create what ever you need without actual coding. It would be nice if FlowStone could support external modules so programmers could collaborate with technicians, so everyone could be best at what they are.
I finding Ruby very difficult to learn (most other languages as well).
For typical programmer probably its hard to see, but programmers have different type of thinking from the rest of the people and programming by typing text works well for them. For people like me who is more technical/electronic based specialist visual programming is easier solution that typical programming. Its like, you do not ask builders to make bricks - you asking them to build building. Same with programming - programmers can be very good on building nodes/building blocks, but not necessary good with ideas,GUI or something else.
I wish there was a visual programming language where you have all necessary building blocks to create what ever you need without actual coding. It would be nice if FlowStone could support external modules so programmers could collaborate with technicians, so everyone could be best at what they are.
- GLIC
- Posts: 11
- Joined: Tue Sep 11, 2018 3:00 pm
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 68 guests