teuben / nemo

a Stellar Dynamics Toolbox (Not Everybody Must Observe)
https://astronemo.readthedocs.io
GNU General Public License v2.0
56 stars 40 forks source link

super basic question for tabtos #115

Open krobsp opened 1 year ago

krobsp commented 1 year ago

Hi ! I have a super basic question for tabtos I have made a txt files containing two lines and 7 columns separated by spaces, see attached. When launching tabtos in=smachin.txt out=snap1.nemo block1=m,pos,vel ndim=3, I get a fatal parsing error. (I know that I had such a problem in the past, but can't remember how to solve...) Could you see the problem ? Thanks ! smachin.txt

teuben commented 1 year ago

When I look at the file, you didn't have a closing newline after the last line, so for unix read lines program that last line never terminated :-) It's easy to create such files with "vim" (maybe emacs too), but it's just not a good idea. I've seen compilers also fail when the last line is such a funky black hole line.

The program hexdump -C smachin.txt show it clearly.

Also, it's a file that comes from DOS, it has CR/NL instead of the unix NL convention for the end of line. I converted them in emacs , but you can also use the dos2unix program.

I will admit though this is an error that NEMO should be able to handle, so I'll put that on the buglist :-) Arguably also the funky last line that never terminated.

teuben commented 1 year ago

An example I tried first to show it should work:

mkplummer - 10 | snapprint - m,x,y,z,vx,vy,vz  > tab2
tabtos tab2 . block1=m,pos,vel
krobsp commented 1 year ago

thank you a lot

teuben commented 1 year ago

The core problem in table.c was resolved, it now reads dos/unix/mac files. However, tabtos doesn't use the new table system yet, so e.g. tabcols (which does use the table I/O) needs to be used in a filter, e.g.

 tabcols smachin.txt  | tabtos - . block1=m,pos,vel nbody=2

will show now errors. If you use not a pipe but a file, the nbody=2 is not needed,as the number of lines is used for nbody :-)

(since table.c was modified, you would need to rebuild NEMO, to be on the safe side,e.g.

   cd $NEMO
  make rebuild
teuben commented 1 year ago

Turns out such a fix was also easy in tabtos, so now it can read DOS and MAC files. The new version of tabtos is 2.1

This command would do that update and recompile:

   mknemo -u tabtos

but this patch doesn't solve the final line problem.