Re: edit-pane-csv separator

2019-02-07 Thread Josef
Hi Terry,

thank you for this update, it is a very welcome improvement - Josef

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: edit-pane-csv separator

2019-01-02 Thread Terry Brown
On Wed, 2 Jan 2019 06:28:15 -0800 (PST)
Josef  wrote:

> Hi Terry,
> 
> sorry it took me a while to get back to you - too much pre-Christmas
> stress.
> 
> Yes, a button to toggle the pane would be fine, I should have thought
> of this. The main issue though is the remembering of the settings,
> since there are many variants of CSV files.

Ok, e74e4e2 lets the CSV edit pane remember per node settings.  It will
work best if you don't move from node to node with the pane open, but
instead open and close the pane on a single node using a button.  Here's
code for the button:


from leo.plugins.editpane.csvedit import LEP_CSVEdit
s = c.free_layout.get_top_splitter()
csv = s.findChild(LEP_CSVEdit)
if csv:
csv.parent().parent().parent().close()
else:
c.k.simulateCommand("edit-pane-csv")


Cheers -Terry

 
> On Sunday, December 2, 2018 at 4:15:45 PM UTC+1, Terry Brown wrote:
> >
> > On Fri, 30 Nov 2018 06:58:59 -0800 (PST) 
> > Josef > wrote: 
> >
> > > Hi Terry, 
> > > 
> > > after using edit-pane-csv for some time now, I have one big wish 
> > > left: it would be great if Leo could remember the settings for
> > > each file, at least for @clean nodes. Ideally the csv pane would
> > > stay open for these nodes. 
> >
> > Would a button that toggled the pane work?  I can't remember if the 
> > code has an easy way to set initial settings, but perhaps per-node 
> > settings could be saved in p.v.u. 
> >
> > Cheers -Terry 
> >
> > > I have many csv files around, which I need to maintain manually
> > > on a regular basis, so it would be nice if Leo could remember the
> > > settings for each of these files, and it would be even better if
> > > I would not have to run the command edit-pane-csv on each file
> > > every time after I closed the associated Leo file. 
> > > 
> > > Cheers - Josef 
> > > 
> > > On Friday, August 10, 2018 at 5:38:37 PM UTC+2, Terry Brown
> > > wrote: 
> > > > 
> > > > On Fri, 10 Aug 2018 08:14:53 -0700 (PDT) 
> > > > Josef > wrote: 
> > > > 
> > > > > Hi Terry 
> > > > > 
> > > > > I tried 
> > > > > 
> > > > > Leo 5.7.4 devel, build 20180807122609 
> > > > > 
> > > > > and it did not work right away with a .latex file. It seems
> > > > > to get confused by the @language latex in the first line. It
> > > > > worked when I removed it. 
> > > > > 
> > > > > It would be nice if it would ignore leo directives. 
> > > > 
> > > > Hmm, it doesn't pay any attention to leo directives, and just 
> > > > defaults to ',' CSV mode.  Not sure what was going on there. 
> > > > 
> > > > > Another quirk is, that every line needs to have the same
> > > > > number of separators, but particularly when editing latex
> > > > > tables by hand one does not always enter all cells if they
> > > > > are empty anyway. This probably is a limitation of the Python
> > > > > CSV library, though. 
> > > > 
> > > > True... hmm, the design is that a series of lines with the same 
> > > > number of separators is what *defines* a table.  Probably 
> > > > reasonable for CSV, but I can see the issue with LaTeX. 
> > > > 
> > > > The simplest way I can think of addressing that would be some
> > > > way to normalize the number of delimiters in a table, either
> > > > have the user select the whole table or incrementally bring in
> > > > lines from above / below the table, adding empty cells to them. 
> > > > 
> > > > But if I remember LaTeX tables, that will impact line drawing, 
> > > > "1 & 2 \\" vs "1 & 2 & & \\" in a four column table for
> > > > example, the first leaves the rest of the line blank whereas
> > > > the second displays empty cells, if you're drawing lines
> > > > between cells that is.  I think. 
> > > > > I think it would also be nice if it could figure out the 
> > > > > separator by itself and start up with a good suggestion,
> > > > > similar to the "sniffer" tool in the CSV module. 
> > > > 
> > > > Might be doable, although I'm guessing that usually you'd only
> > > > need to change it once per session, and having it guess too
> > > > often might make it less flexible in terms of editing different
> > > > table types in the same node etc.  I did think of adding a
> > > > presets dropdown for CSV / tab / LaTeX / pipe etc. 
> > > > 
> > > > > That all said, thank you very much for this command. It makes
> > > > > my life a lot easier. 
> > > > 
> > > > Glad to hear it. 
> > > > 
> > > > Cheers -Terry 
> > > > 
> > > 
> >
> 

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: edit-pane-csv separator

2019-01-02 Thread Josef
Hi Terry,

sorry it took me a while to get back to you - too much pre-Christmas stress.

Yes, a button to toggle the pane would be fine, I should have thought of 
this. The main issue though is the remembering of the settings, since there 
are many variants of CSV files.

On Sunday, December 2, 2018 at 4:15:45 PM UTC+1, Terry Brown wrote:
>
> On Fri, 30 Nov 2018 06:58:59 -0800 (PST) 
> Josef > wrote: 
>
> > Hi Terry, 
> > 
> > after using edit-pane-csv for some time now, I have one big wish 
> > left: it would be great if Leo could remember the settings for each 
> > file, at least for @clean nodes. Ideally the csv pane would stay open 
> > for these nodes. 
>
> Would a button that toggled the pane work?  I can't remember if the 
> code has an easy way to set initial settings, but perhaps per-node 
> settings could be saved in p.v.u. 
>
> Cheers -Terry 
>
> > I have many csv files around, which I need to maintain manually on a 
> > regular basis, so it would be nice if Leo could remember the settings 
> > for each of these files, and it would be even better if I would not 
> > have to run the command edit-pane-csv on each file every time after I 
> > closed the associated Leo file. 
> > 
> > Cheers - Josef 
> > 
> > On Friday, August 10, 2018 at 5:38:37 PM UTC+2, Terry Brown wrote: 
> > > 
> > > On Fri, 10 Aug 2018 08:14:53 -0700 (PDT) 
> > > Josef > wrote: 
> > > 
> > > > Hi Terry 
> > > > 
> > > > I tried 
> > > > 
> > > > Leo 5.7.4 devel, build 20180807122609 
> > > > 
> > > > and it did not work right away with a .latex file. It seems to 
> > > > get confused by the @language latex in the first line. It worked 
> > > > when I removed it. 
> > > > 
> > > > It would be nice if it would ignore leo directives. 
> > > 
> > > Hmm, it doesn't pay any attention to leo directives, and just 
> > > defaults to ',' CSV mode.  Not sure what was going on there. 
> > > 
> > > > Another quirk is, that every line needs to have the same number 
> > > > of separators, but particularly when editing latex tables by hand 
> > > > one does not always enter all cells if they are empty anyway. 
> > > > This probably is a limitation of the Python CSV library, though. 
> > > 
> > > True... hmm, the design is that a series of lines with the same 
> > > number of separators is what *defines* a table.  Probably 
> > > reasonable for CSV, but I can see the issue with LaTeX. 
> > > 
> > > The simplest way I can think of addressing that would be some way 
> > > to normalize the number of delimiters in a table, either have the 
> > > user select the whole table or incrementally bring in lines from 
> > > above / below the table, adding empty cells to them. 
> > > 
> > > But if I remember LaTeX tables, that will impact line drawing, 
> > > "1 & 2 \\" vs "1 & 2 & & \\" in a four column table for example, 
> > > the first leaves the rest of the line blank whereas the second 
> > > displays empty cells, if you're drawing lines between cells that 
> > > is.  I think. 
> > > > I think it would also be nice if it could figure out the 
> > > > separator by itself and start up with a good suggestion, similar 
> > > > to the "sniffer" tool in the CSV module. 
> > > 
> > > Might be doable, although I'm guessing that usually you'd only need 
> > > to change it once per session, and having it guess too often might 
> > > make it less flexible in terms of editing different table types in 
> > > the same node etc.  I did think of adding a presets dropdown for 
> > > CSV / tab / LaTeX / pipe etc. 
> > > 
> > > > That all said, thank you very much for this command. It makes my 
> > > > life a lot easier. 
> > > 
> > > Glad to hear it. 
> > > 
> > > Cheers -Terry 
> > > 
> > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: edit-pane-csv separator

2018-12-02 Thread Terry Brown
On Fri, 30 Nov 2018 06:58:59 -0800 (PST)
Josef  wrote:

> Hi Terry,
> 
> after using edit-pane-csv for some time now, I have one big wish
> left: it would be great if Leo could remember the settings for each
> file, at least for @clean nodes. Ideally the csv pane would stay open
> for these nodes.

Would a button that toggled the pane work?  I can't remember if the
code has an easy way to set initial settings, but perhaps per-node
settings could be saved in p.v.u.

Cheers -Terry

> I have many csv files around, which I need to maintain manually on a 
> regular basis, so it would be nice if Leo could remember the settings
> for each of these files, and it would be even better if I would not
> have to run the command edit-pane-csv on each file every time after I
> closed the associated Leo file.
> 
> Cheers - Josef
> 
> On Friday, August 10, 2018 at 5:38:37 PM UTC+2, Terry Brown wrote:
> >
> > On Fri, 10 Aug 2018 08:14:53 -0700 (PDT) 
> > Josef > wrote: 
> >
> > > Hi Terry 
> > > 
> > > I tried 
> > > 
> > > Leo 5.7.4 devel, build 20180807122609 
> > > 
> > > and it did not work right away with a .latex file. It seems to
> > > get confused by the @language latex in the first line. It worked
> > > when I removed it. 
> > > 
> > > It would be nice if it would ignore leo directives. 
> >
> > Hmm, it doesn't pay any attention to leo directives, and just
> > defaults to ',' CSV mode.  Not sure what was going on there. 
> >
> > > Another quirk is, that every line needs to have the same number
> > > of separators, but particularly when editing latex tables by hand
> > > one does not always enter all cells if they are empty anyway.
> > > This probably is a limitation of the Python CSV library, though. 
> >
> > True... hmm, the design is that a series of lines with the same
> > number of separators is what *defines* a table.  Probably
> > reasonable for CSV, but I can see the issue with LaTeX. 
> >
> > The simplest way I can think of addressing that would be some way
> > to normalize the number of delimiters in a table, either have the
> > user select the whole table or incrementally bring in lines from
> > above / below the table, adding empty cells to them. 
> >
> > But if I remember LaTeX tables, that will impact line drawing, 
> > "1 & 2 \\" vs "1 & 2 & & \\" in a four column table for example,
> > the first leaves the rest of the line blank whereas the second
> > displays empty cells, if you're drawing lines between cells that
> > is.  I think. 
> > > I think it would also be nice if it could figure out the
> > > separator by itself and start up with a good suggestion, similar
> > > to the "sniffer" tool in the CSV module. 
> >
> > Might be doable, although I'm guessing that usually you'd only need
> > to change it once per session, and having it guess too often might
> > make it less flexible in terms of editing different table types in
> > the same node etc.  I did think of adding a presets dropdown for
> > CSV / tab / LaTeX / pipe etc. 
> >
> > > That all said, thank you very much for this command. It makes my
> > > life a lot easier. 
> >
> > Glad to hear it. 
> >
> > Cheers -Terry 
> >
> 

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: edit-pane-csv separator

2018-11-30 Thread Josef
Hi Terry,

after using edit-pane-csv for some time now, I have one big wish left: it 
would be great if Leo could remember the settings for each file, at least 
for @clean nodes. Ideally the csv pane would stay open for these nodes.

I have many csv files around, which I need to maintain manually on a 
regular basis, so it would be nice if Leo could remember the settings for 
each of these files, and it would be even better if I would not have to run 
the command edit-pane-csv on each file every time after I closed the 
associated Leo file.

Cheers - Josef

On Friday, August 10, 2018 at 5:38:37 PM UTC+2, Terry Brown wrote:
>
> On Fri, 10 Aug 2018 08:14:53 -0700 (PDT) 
> Josef > wrote: 
>
> > Hi Terry 
> > 
> > I tried 
> > 
> > Leo 5.7.4 devel, build 20180807122609 
> > 
> > and it did not work right away with a .latex file. It seems to get 
> > confused by the @language latex in the first line. It worked when I 
> > removed it. 
> > 
> > It would be nice if it would ignore leo directives. 
>
> Hmm, it doesn't pay any attention to leo directives, and just defaults 
> to ',' CSV mode.  Not sure what was going on there. 
>
> > Another quirk is, that every line needs to have the same number of 
> > separators, but particularly when editing latex tables by hand one 
> > does not always enter all cells if they are empty anyway. This 
> > probably is a limitation of the Python CSV library, though. 
>
> True... hmm, the design is that a series of lines with the same number 
> of separators is what *defines* a table.  Probably reasonable for CSV, 
> but I can see the issue with LaTeX. 
>
> The simplest way I can think of addressing that would be some way to 
> normalize the number of delimiters in a table, either have the user 
> select the whole table or incrementally bring in lines from above / 
> below the table, adding empty cells to them. 
>
> But if I remember LaTeX tables, that will impact line drawing, 
> "1 & 2 \\" vs "1 & 2 & & \\" in a four column table for example, the 
> first leaves the rest of the line blank whereas the second displays 
> empty cells, if you're drawing lines between cells that is.  I think. 
>   
> > I think it would also be nice if it could figure out the separator by 
> > itself and start up with a good suggestion, similar to the "sniffer" 
> > tool in the CSV module. 
>
> Might be doable, although I'm guessing that usually you'd only need to 
> change it once per session, and having it guess too often might make it 
> less flexible in terms of editing different table types in the same 
> node etc.  I did think of adding a presets dropdown for CSV / tab / 
> LaTeX / pipe etc. 
>
> > That all said, thank you very much for this command. It makes my life 
> > a lot easier. 
>
> Glad to hear it. 
>
> Cheers -Terry 
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: edit-pane-csv separator

2018-08-07 Thread Terry Brown
On Tue, 7 Aug 2018 04:27:10 -0700 (PDT)
Josef  wrote:

> Perhaps it is best/easiest not to touch the cell content at all, and
> leave such alignment things to a separate command? Otherwise you may
> end up having to remember the alignment strategy for each file.

Right, the alignment stuff I'm not going to deal with.  But I'm pleased
with the enhancements I've just pushed to devel.  Whereas before you
could just edit comma separated data, now you can use any separator,
*and* you can add a line start / line end string.  So for a LaTeX table
you can use ' & ' () as the separator, and
' \\' () as the line ending.

Use \t to represent tabs.

A behind the scenes complication is that I want to keep using Python's
csv lib. to parse the data, and that only allows single character
separators.  I get around that by replacing the user visible separator,
which may be multi-character, with a single character that doesn't
occur in the text - have to search for that.

I want to keep using the lib. to support CSV like

count, description
7, otters
12, "rats, mice"

although I'm not sure that part's working at the moment.

Anyway, Leo is even better at editing tables now, thanks Josef :)

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: edit-pane-csv separator

2018-08-07 Thread Josef
Hi Terry,

Am Dienstag, 7. August 2018 05:51:43 UTC+2 schrieb Terry Brown:
>
> On Mon, 6 Aug 2018 05:46:55 -0700 (PDT) 
> Josef > wrote: 
>
> > Is there a way to set the CSV separator? 
>
> I've made a start on this in the csv_delim branch. 
>
> It's not finished, because I'm trying to cover the LaTeX table case: 
>
> 1 & 2 & 3 \\ 
> a & b & c \\ 
>
> My initial thought was to let the delimiter be a regex, &| in the 
> above case, but then what do you use to put the delimiters back in, & 
> or \\?  We know it's & except at the end of the line, but that's LaTeX 
> specific. 
>
> Also allows delimiters like [,;], i.e. , or ; - but again, which do you 
> use to reconstruct the text? 
>
> I think perhaps regex is a bad idea, and I should just extend 
> edit-pane-csv to allow any set string as a delimiter, and right 
> edit-pane-latex-table as a special case. 
>

I see the problem. Yes, LaTeX is always a special case - I don't recall any 
other textual table representation with an "end of record" separator,
so if you are going to implement the LaTeX case, I think it is best to make 
it a special case also in the code.  If you want to cover everything you 
need to look at org-mode tables too - but that could be quite complicated.

That said, when writing text back there is always the question of makeing 
it pretty or not. If the file is to be used with LibreOffice or Excel, then 
you might want to write it back without any further adjustments. In some 
cases I even had problems with leading spaces in cells.

When the text file is being edited by others too, things become a bit more 
complicated. This is of course quite often the case with LaTeX. In such a 
case it may be good to insert spaces after the cell content, so the 
separators line up in any normal text editor.

And now it gets even more complicated: In some textual table 
representations leading and trailing spaces are meaningful, because the 
indicate the alignment (left, right or centered). I think that is the case 
for org-mode as well as for ReST, but I am not sure any more. In that case 
the default would be to re-create the existing alignment, and have the 
option to change it.

Perhaps it is best/easiest not to touch the cell content at all, and leave 
such alignment things to a separate command? Otherwise you may end up 
having to remember the alignment strategy for each file.

- Josef


-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: edit-pane-csv separator

2018-08-06 Thread Terry Brown
On Mon, 6 Aug 2018 05:46:55 -0700 (PDT)
Josef  wrote:

> Is there a way to set the CSV separator?

I've made a start on this in the csv_delim branch.

It's not finished, because I'm trying to cover the LaTeX table case:

1 & 2 & 3 \\
a & b & c \\

My initial thought was to let the delimiter be a regex, &| in the
above case, but then what do you use to put the delimiters back in, &
or \\?  We know it's & except at the end of the line, but that's LaTeX
specific.

Also allows delimiters like [,;], i.e. , or ; - but again, which do you
use to reconstruct the text?

I think perhaps regex is a bad idea, and I should just extend
edit-pane-csv to allow any set string as a delimiter, and right
edit-pane-latex-table as a special case.

But not tonight.

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: edit-pane-csv separator

2018-08-06 Thread Edward K. Ream
On Mon, Aug 6, 2018 at 7:46 AM, Josef  wrote:

To my delight I just found out that leo has since a couple of versions the
> command edit-pane-csv.
>


> Is there a way to set the CSV separator?
>

Terry should know.  He wrote the editpane.py plugin.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


edit-pane-csv separator

2018-08-06 Thread Josef
To my delight I just found out that leo has since a couple of versions the 
command edit-pane-csv.
This is extremely useful!

My problem is, that I have to deal with many CSV files, which often are 
tab-separated of semicolon separated.

So far I was only able to edit comma-separated files with this command.

Since I also could not find any documentation, I am asking this question 
here:

Is there a way to set the CSV separator?

Ideally it should allow arbitrary separators, but at least commas, tabs and 
semicolons, since these are very common (in Europe, Excel uses a semicolon, 
since the comma is used as decimal separator instead of a dot here).

Now for the "pie in the sky" wishes:

Even better would be to allow also "&" and simultaneously "\\" (two 
backslashes) as separator.
That way LaTeX tables could be more easily edited too.
LaTeX uses "&" as separator and a double backslash at the end of each row,
however there could be additional commands following the double backslash, 
like "\midrule".
The double backslash and anything that follows it, should remain at the end 
of their rows,
even if the last column is moved.
In the case o LaTeX tables, It would be even better if the source code 
would get aligned as well (all the "&"  aligning).

Also, is this command capable of allowing fields with embedded newline 
characters (not just at the end of each record, but inside a string as part 
of the string) ?

- Josef

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.