convert html table to Lyx
I made a table in Lyx (cvs version). It starts with: \begin_inset Tabular lyxtabular version=3 rows=9 columns=3 features column alignment=center valignment=top leftline=true width=0 column alignment=center valignment=top leftline=true width=0 column alignment=center valignment=top leftline=true rightline=true wid th=0 row topline=true bottomline=true cell alignment=center valignment=top topline=true leftline=true usebox= none \begin_inset Text My problem is that HTML tables (by default) do not know how many columns or rows they may have. For example, I may have some: table tr td data /td td data /td /tr tr td data /td td data /td /tr /table Is there any way in lyx to have tables without defining how many rows or columns ahead of time? Maybe I should use latex table or tabular? I have some XML documents that I am converting to Lyx and it is going well, but now I am trying to figure out the tables part. I have table, row, item, table heading, but no references ahead of time of how many rows or items. Anyone have any example of doing this? Jeremy C. Reed BSD News, BSD tutorials, BSD links http://www.bsdnewsletter.com/
Re: convert html table to Lyx
On Wed, Sep 29, 2004 at 01:22:16PM -0700, Jeremy C. Reed wrote: I made a table in Lyx (cvs version). Is there any way in lyx to have tables without defining how many rows or columns ahead of time? No. Maybe I should use latex table or tabular? I see two: - make a script (in python ;-) to convert the tables specifically - convert the table to latex and use tex2lyx to convert the resulting table. I have some XML documents that I am converting to Lyx and it is going well, but now I am trying to figure out the tables part. What are you using to convert them, xsl? I have table, row, item, table heading, but no references ahead of time of how many rows or items. Anyone have any example of doing this? I have done most of the work of converting previous file format of lyx to the latest for tables. And it was reasonably easy using python. I'm serious. :-) Jeremy C. Reed BSD News, BSD tutorials, BSD links http://www.bsdnewsletter.com/ -- José Abílio Matos LyX and docbook a perfect match. :-)
Re: convert html table to Lyx
Jeremy C. Reed wrote: I made a table in Lyx (cvs version). It starts with: \begin_inset Tabular lyxtabular version=3 rows=9 columns=3 features column alignment=center valignment=top leftline=true width=0 column alignment=center valignment=top leftline=true width=0 column alignment=center valignment=top leftline=true rightline=true wid th=0 row topline=true bottomline=true cell alignment=center valignment=top topline=true leftline=true usebox= none \begin_inset Text My problem is that HTML tables (by default) do not know how many columns or rows they may have. For example, I may have some: table tr td data /td td data /td /tr tr td data /td td data /td /tr /table Is there any way in lyx to have tables without defining how many rows or columns ahead of time? No. I'd agree that LyX's table format sucks, but the data is there in your html file. Why not just extract it? Attached is a python script that does it for you. Regards, Angus #! /usr/bin/env python import re, string, sys def usage(prog_name): print Usage: %s data file\n % prog_name return 1 def error(message): sys.stderr.write(message + '\n') sys.exit(1) def read_file(data_file): try: data = for line in open(data_file, 'r').readlines(): data = data + ' ' + string.strip(line) return data except: # Unable to open the file error(Unable to open + data_file) def delimit_table(data, startpos): table_start = string.find(data, table, startpos) if table_start == -1: return None, None table_end = string.find(data, /table, table_start) if table_end == -1: return None, None return table_start, table_end + len(/table) def delimit_row(data, startpos): row_start = string.find(data, tr, startpos) if row_start == -1: return None, None row_end = string.find(data, /tr, row_start) if row_end == -1: return None, None return row_start, row_end + len(/tr) def delimit_col(data, startpos): col_start = string.find(data, td, startpos) if col_start == -1: return None, None col_end = string.find(data, /td, col_start) if col_end == -1: return None, None return col_start, col_end + len(/td) def extract_rows_cols(data, start, end): rows = 0 cols = 0 startrow = start while (1): startrow, endrow = delimit_row(data, startrow) if startrow == None: break if endrow end: break rows = rows + 1 startcol = startrow cols_row = 0 while (1): startcol, endcol = delimit_col(data, startcol) if startcol == None: break if endcol endrow: break cols_row = cols_row + 1 startcol = endcol cols = max(cols, cols_row) startrow = endrow return rows, cols def main(argv): if len(argv) != 2: return usage(argv[0]) data = read_file(argv[1]) start = 0 while (1): start, end = delimit_table(data, start) if start == None: break rows, cols = extract_rows_cols(data, start, end) print data[start:end] print Table has , rows, rows and , cols, cols. start = end #print data if __name__ == __main__: main(sys.argv)
convert html table to Lyx
I made a table in Lyx (cvs version). It starts with: \begin_inset Tabular lyxtabular version=3 rows=9 columns=3 features column alignment=center valignment=top leftline=true width=0 column alignment=center valignment=top leftline=true width=0 column alignment=center valignment=top leftline=true rightline=true wid th=0 row topline=true bottomline=true cell alignment=center valignment=top topline=true leftline=true usebox= none \begin_inset Text My problem is that HTML tables (by default) do not know how many columns or rows they may have. For example, I may have some: table tr td data /td td data /td /tr tr td data /td td data /td /tr /table Is there any way in lyx to have tables without defining how many rows or columns ahead of time? Maybe I should use latex table or tabular? I have some XML documents that I am converting to Lyx and it is going well, but now I am trying to figure out the tables part. I have table, row, item, table heading, but no references ahead of time of how many rows or items. Anyone have any example of doing this? Jeremy C. Reed BSD News, BSD tutorials, BSD links http://www.bsdnewsletter.com/
Re: convert html table to Lyx
On Wed, Sep 29, 2004 at 01:22:16PM -0700, Jeremy C. Reed wrote: I made a table in Lyx (cvs version). Is there any way in lyx to have tables without defining how many rows or columns ahead of time? No. Maybe I should use latex table or tabular? I see two: - make a script (in python ;-) to convert the tables specifically - convert the table to latex and use tex2lyx to convert the resulting table. I have some XML documents that I am converting to Lyx and it is going well, but now I am trying to figure out the tables part. What are you using to convert them, xsl? I have table, row, item, table heading, but no references ahead of time of how many rows or items. Anyone have any example of doing this? I have done most of the work of converting previous file format of lyx to the latest for tables. And it was reasonably easy using python. I'm serious. :-) Jeremy C. Reed BSD News, BSD tutorials, BSD links http://www.bsdnewsletter.com/ -- José Abílio Matos LyX and docbook a perfect match. :-)
Re: convert html table to Lyx
Jeremy C. Reed wrote: I made a table in Lyx (cvs version). It starts with: \begin_inset Tabular lyxtabular version=3 rows=9 columns=3 features column alignment=center valignment=top leftline=true width=0 column alignment=center valignment=top leftline=true width=0 column alignment=center valignment=top leftline=true rightline=true wid th=0 row topline=true bottomline=true cell alignment=center valignment=top topline=true leftline=true usebox= none \begin_inset Text My problem is that HTML tables (by default) do not know how many columns or rows they may have. For example, I may have some: table tr td data /td td data /td /tr tr td data /td td data /td /tr /table Is there any way in lyx to have tables without defining how many rows or columns ahead of time? No. I'd agree that LyX's table format sucks, but the data is there in your html file. Why not just extract it? Attached is a python script that does it for you. Regards, Angus #! /usr/bin/env python import re, string, sys def usage(prog_name): print Usage: %s data file\n % prog_name return 1 def error(message): sys.stderr.write(message + '\n') sys.exit(1) def read_file(data_file): try: data = for line in open(data_file, 'r').readlines(): data = data + ' ' + string.strip(line) return data except: # Unable to open the file error(Unable to open + data_file) def delimit_table(data, startpos): table_start = string.find(data, table, startpos) if table_start == -1: return None, None table_end = string.find(data, /table, table_start) if table_end == -1: return None, None return table_start, table_end + len(/table) def delimit_row(data, startpos): row_start = string.find(data, tr, startpos) if row_start == -1: return None, None row_end = string.find(data, /tr, row_start) if row_end == -1: return None, None return row_start, row_end + len(/tr) def delimit_col(data, startpos): col_start = string.find(data, td, startpos) if col_start == -1: return None, None col_end = string.find(data, /td, col_start) if col_end == -1: return None, None return col_start, col_end + len(/td) def extract_rows_cols(data, start, end): rows = 0 cols = 0 startrow = start while (1): startrow, endrow = delimit_row(data, startrow) if startrow == None: break if endrow end: break rows = rows + 1 startcol = startrow cols_row = 0 while (1): startcol, endcol = delimit_col(data, startcol) if startcol == None: break if endcol endrow: break cols_row = cols_row + 1 startcol = endcol cols = max(cols, cols_row) startrow = endrow return rows, cols def main(argv): if len(argv) != 2: return usage(argv[0]) data = read_file(argv[1]) start = 0 while (1): start, end = delimit_table(data, start) if start == None: break rows, cols = extract_rows_cols(data, start, end) print data[start:end] print Table has , rows, rows and , cols, cols. start = end #print data if __name__ == __main__: main(sys.argv)
convert html table to Lyx
I made a table in Lyx (cvs version). It starts with: \begin_inset Tabular \begin_inset Text My problem is that HTML tables (by default) do not know how many columns or rows they may have. For example, I may have some: data data data data Is there any way in lyx to have tables without defining how many rows or columns ahead of time? Maybe I should use latex table or tabular? I have some XML documents that I am converting to Lyx and it is going well, but now I am trying to figure out the tables part. I have table, row, item, table heading, but no references ahead of time of how many rows or items. Anyone have any example of doing this? Jeremy C. Reed BSD News, BSD tutorials, BSD links http://www.bsdnewsletter.com/
Re: convert html table to Lyx
On Wed, Sep 29, 2004 at 01:22:16PM -0700, Jeremy C. Reed wrote: > I made a table in Lyx (cvs version). > > > Is there any way in lyx to have tables without defining how many rows or > columns ahead of time? No. > Maybe I should use latex table or tabular? I see two: - make a script (in python ;-) to convert the tables specifically - convert the table to latex and use tex2lyx to convert the resulting table. > I have some XML documents that I am converting to Lyx and it is going > well, but now I am trying to figure out the tables part. What are you using to convert them, xsl? > I have table, row, item, table heading, but no references ahead of time of > how many rows or items. > > Anyone have any example of doing this? I have done most of the work of converting previous file format of lyx to the latest for tables. And it was reasonably easy using python. I'm serious. :-) > Jeremy C. Reed > >BSD News, BSD tutorials, BSD links >http://www.bsdnewsletter.com/ -- José Abílio Matos LyX and docbook a perfect match. :-)
Re: convert html table to Lyx
Jeremy C. Reed wrote: > I made a table in Lyx (cvs version). > > It starts with: > > \begin_inset Tabular > > > > > rightline="true" wid > th="0"> > > usebox= > "none"> > \begin_inset Text > > > My problem is that HTML tables (by default) do not know how many columns > or rows they may have. > > For example, I may have some: > > > > > data > > > data > > > > > data > > > data > > > > > Is there any way in lyx to have tables without defining how many rows or > columns ahead of time? No. I'd agree that LyX's table format sucks, but the data is there in your html file. Why not just extract it? Attached is a python script that does it for you. Regards, Angus #! /usr/bin/env python import re, string, sys def usage(prog_name): print "Usage: %s \n" % prog_name return 1 def error(message): sys.stderr.write(message + '\n') sys.exit(1) def read_file(data_file): try: data = "" for line in open(data_file, 'r').readlines(): data = data + ' ' + string.strip(line) return data except: # Unable to open the file error("Unable to open " + data_file) def delimit_table(data, startpos): table_start = string.find(data, "end: break rows = rows + 1 startcol = startrow cols_row = 0 while (1): startcol, endcol = delimit_col(data, startcol) if startcol == None: break if endcol > endrow: break cols_row = cols_row + 1 startcol = endcol cols = max(cols, cols_row) startrow = endrow return rows, cols def main(argv): if len(argv) != 2: return usage(argv[0]) data = read_file(argv[1]) start = 0 while (1): start, end = delimit_table(data, start) if start == None: break rows, cols = extract_rows_cols(data, start, end) print data[start:end] print "Table has ", rows, " rows and ", cols, "cols." start = end #print data if __name__ == "__main__": main(sys.argv)