I have a file text with 20k lines. Each line has an x, y, and z variable.
> X:40.23 Y:10.30 Z:15.13
I need to replace every line with an increase of 40 in the X and Y place. The above line would look like this:
>X:80.23 Y:30.10 Z:15.13
How?
pic related.
>>54386024
Learn to program.
>>54386137
This. I could write a 10 line python script that does this, probably even less.
>>54386024
quick and dirty?
import into excel as custom CSV
map formula onto those two columns, overwrite, export.
>>54386024
Waiting for that sh guru who will solve this in one line.
>>54386024
if this is for cnc machining, you could just set the ucs at the new origin, or work with another zero offset.
>>54386024
sed
>>54386024
Leave the file alone and set an offset
Just change your offsets faggot
Also, what program gets anywhere near 20k lines?
>>54386024
>square caps
why ?
I'm also wondering how this situation arises in the first place, not only do you have 20k lines of code, which I'm having trouble believing because even the most complicated shit reaches 2k lines max if you're any good, and you have some reason to move everything on the x plane +40 units
You better be in base thou or tenthou if you managed to fuck up that bad
Change your tooling offsets, no need to edit the code
ruby:arr = "X:40.23 Y:10.30 Z:15.13".scan(/\d+[.]\d+/).map!{|element| element.to_f + 40}
puts "X:#{arr[0]} Y:#{arr[1]} Z:#{arr[2]}"
this puts on the screen:
X:80.22999999999999 Y:50.3 Z:55.13
just parse each line
>>54386024
disregarding you said +40 in X and Y and only added 20 for Y, pythondef clean(data):
x, y, z = (float(item.split(" ")[0]) for item in data.split(":")[1:])
return "X:{:.2f} Y:{:.2f} Z:{:.2f}".format(x + 40, y + 40, z)
with open("text.txt") as file:
text = file.read()
with open("new-text.txt") as file:
file.write('\n'.join(clean(line) for line in text.split('\n')))