Repository navigation
InconsistentTableError: Lines in LaTeX table have to end with \\ #4576
Description
In refrence solve the previous issue when i tried to run latex file it result in the following issue
Latex reader should accept tables without \begin/\end #4295
from astropy.table import Table
In [41]: dat = Table.read('sample.tex', format='latex')
InconsistentTableError Traceback (most recent call last)
in ()
----> 1 dat = Table.read('sample.tex', format='latex')
/home/dell/astropy/astropy/table/table.pyc in read(cls, _args, *_kwargs)
2291 passed through to the underlying data reader (e.g. ~astropy.io.ascii.read).
2292 """
-> 2293 return io_registry.read(cls, _args, *_kwargs)
2294
2295 def write(self, _args, *_kwargs):
/home/dell/astropy/astropy/io/registry.pyc in read(cls, _args, *_kwargs)
342
343 reader = get_reader(format, cls)
--> 344 data = reader(_args, *_kwargs)
345
346 if not isinstance(data, cls):
/home/dell/astropy/astropy/io/ascii/connect.pyc in io_read(format, filename, *_kwargs)
35 from .ui import read
36 format = re.sub(r'^ascii.', '', format)
---> 37 return read(filename, format=format, *_kwargs)
38
39
/home/dell/astropy/astropy/io/ascii/ui.pyc in read(table, guess, **kwargs)
337 ' with fast (no guessing)'})
338 else:
--> 339 dat = reader.read(table)
340 _read_trace.append({'kwargs': new_kwargs,
341 'status': 'Success with specified Reader class '
/home/dell/astropy/astropy/io/ascii/core.pyc in read(self, table)
1043
1044 # Get the table column definitions
-> 1045 self.header.get_cols(self.lines)
1046
1047 # Make sure columns are valid
/home/dell/astropy/astropy/io/ascii/core.pyc in get_cols(self, lines)
480 raise ValueError('No header line found in table')
481
--> 482 self.names = next(self.splitter([line]))
483
484 self._set_cols_from_names()
/home/dell/astropy/astropy/io/ascii/core.pyc in call(self, lines)
244 if self.process_line:
245 lines = (self.process_line(x) for x in lines)
--> 246 for line in lines:
247 vals = line.split(self.delimiter)
248 if self.process_val:
/home/dell/astropy/astropy/io/ascii/core.pyc in ((x,))
243 def call(self, lines):
244 if self.process_line:
--> 245 lines = (self.process_line(x) for x in lines)
246 for line in lines:
247 vals = line.split(self.delimiter)
/home/dell/astropy/astropy/io/ascii/latex.pyc in process_line(self, line)
88 line = line.strip(r'')
89 else:
---> 90 raise core.InconsistentTableError(r'Lines in LaTeX table have to end with ')
91 return line
92
InconsistentTableError: Lines in LaTeX table have to end with \
We must change the code in latex.py read function because its common error when tried to read a latex filr
Activity
hamogu commentedon Feb 9, 2016
Can you post you "sample.tex" files somewhere (maybe in a gist) so that I can try to reproduce the problem?
The LaTeX reader currently has some limitations, see also #1525 most importantly it expects each table row to be on one and only one line, but it also cannot deal with
\multicolumnor\multirowcommands, etc.While I agree that it would be great to be a little more flexible in reading, we will never be able to cover all LaTeX features.
sample tex file to fix InconsistentTableError: Lines in LaTeX table h…
hamogu commentedon Feb 10, 2016
Do you want to work on this?
It's not clear to me how to solve this best, but if you have an idea that would be great.
(Note: In general it is the best to provide an example table outside of the astropy repro. We dont' want large files in there like your example that are not needed for astropy itself.) If we ever merge anything from your branch the nthis file will be part of the git history, making the astropy repository bigger and slower to download for everyone. So, if you work on this, please start a new branch and do not continue from the branch you pushed here.)
AMAN3003 commentedon Feb 11, 2016
@hamogu I would like to work on this
hamogu commentedon Feb 11, 2016
Great! Looking forward to see what you can come up with.
A word of advice: I suggest that you start with a small step and when that works you wrote tests for it and push it here, so we can see if you are on the right track.
sample tex file to fix InconsistentTableError: Lines in LaTeX table h…
hamogu commentedon Jan 10, 2025
This has been solved (see #5160). I'm not sure why this issue is still open, but it seems that that's an oversight, so I'm closing it.