0

I am using a Unix-based program. I want to automate the code so as not to copy and paste data one by one. For this, I need to define line-by-line data in a file as a variable for the code.

The program converts xyz coordinates to local coordinates. How can I run the coordinates in the xyz_coordinates file I created, one by one, in the code below? In the program I use, the conversion code works like this,

echo 4208830.039709186 2334850.551667509 4171267.377406844 -6.753E-01 4.493E-01 2.849E-01  | xyz2env.py

and this is the file I am trying to run,

2679689.926729193 -727950.9964290063 5722789.538975053 7.873E-02 3.466E-01 6.410E-01

2679689.927123377 -727950.9971557076 5722789.540522 7.912E-02 3.458E-01 6.425E-01

2679689.930567728 -727950.9979971027 5722789.550832021 8.257E-02 3.450E-01 6.528E-01

2679689.931029495 -727950.9992263148 5722789.549927638 8.303E-02 3.438E-01 6.519E-01

2679689.929031829 -727950.9981009626 5722789.546359798 8.103E-02 3.449E-01 6.484E-01
........

and goes on like this. Also, there are spaces between the lines. Will this be a problem?

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • 2
    Please don't ask multiple questions in the same post – Nico Haase Dec 19 '22 at 13:23
  • tail -n 2 | (regX replace ^\s+$ with null - not regx syntax) >> xyz_coordinates, use regular expression to replace lines with white space, see this answer for regx, https://stackoverflow.com/questions/24796205/using-regex-to-delete-extra-empty-lines-of-a-text – MZM Dec 19 '22 at 14:40
  • A simple `while read -r` loop where you discard empty lines would seem like the obvious solution. Alternatively, to discard empty lines, `grep -Fvx '' file` which you can then pipe to `while` (or `xargs` etc). – tripleee Dec 21 '22 at 07:41

0 Answers0